Reputation: 16349
I'm making a library that consists of multiple classes.
Here are the files used:
mylib.cpp
mylib_global.h //Qt requirement for shared lib
mylib.h //This is what i'd like to import
oneclass.cpp //The classes below provide the functionality
oneclass.h
twoclass.cpp
twoclass.h
I would like to achieve the following:
#include "mylib.h"
int main(int argc, char *argv[])
{
OneClass oneClass;
TwoClass twoClass;
}
So, i'm just importing the mylib.h
in some other application header and because of it the OneClass
and TwoClass
are available there.
Can this be achieved? Also, please comment if this is a conceptually wrong way to implement libraries, and if so, why?
Upvotes: 0
Views: 250
Reputation: 10406
Yes, that can be achieved.
Simply include all public definitions that your libraries provide into the libraries main header file. In your example make mylib.h should look like as follows:
#include "oneclass.h"
#include "twoclass.h"
Upvotes: 3