I am new to C++ modules. Let’s say I am creating dll , and I don’t want my users to see implementation details of my class . How can I achieve this in C++ modules ? Mostly I am seeing examples over internet , implementing functions in the same file . Can I safely say , module interfaces are similar to header files & module implementation is similar to cpp file ?
Here is my example implementation , is this correct ? I am using visual studio 2022.
//AnimalParent.ixx file
export module Animal:Parent;
export class Animal
{
public:
virtual void say();
};
//AnimalParent.cpp file
module Animal:Parent;
#include <iostream>
void Animal::say()
{
std::cout << "I am Animal" << std::endl;
}
//Animal.cat.ixx file
export module Animal:Cat;
import :Parent;
export class Cat :public Animal
{
public:
void say() override;
};
//AnimalCat.cpp file
module Animal:Cat;
#include <iostream>
void Cat::say()
{
std::cout << "I am cat" << std::endl;
}
//Animal.ixx file
export module Animal;
export import :Parent;
export import :Cat;
questions :
- Is this implementation correct ?
- can I safely assume , files contain
export module name(.ixx extension)
– similar to header files &module name
– similar to respective source file ? - If I shift this dll to my customer , what all should I give ? my dll and the folder contains
.ixx
files? - And how they will integrate my dll . in current header files system , they will refer to header files directory to
Additional include directories
, and link the lib. Here do they have to refer the folder contains.ixx
files inAdditional include directories
& link the lib.