Can someone tell me what is the correct way to create a .hpp and .cpp that includes classes, subclasses and methods? Do I have to use export "C" firstClass* create_object { return new firstClass; }
? (I am working in C++.) Should I have file.hpp
or file.h
?
#include <string>
//public ?? how can i have this?
class firstClass
{
public:
firstClass();
class secondClass
{
public:
secondClass();
std::string name;
virtual std::string method1();
} *sec;
virtual void DoSomething();
} *first;
// And for a private class?
class private *priv;
in file.cpp
#include file.hpp
firstClass::firstClass()
{
sec = new firstClass::secondClass();
}
std::string firstClass::secondClass::method1()
{
//code
}
And now if I have to extern
an object for each class/subclass? It is necessary if I want to create an .so file and use dlsym and dlopen to access classes, subclasses and methods, modify values, send a reference to a specific method? Thanks!
extern "C" firstClass* create_object()
{return new firstClass}
extern "C" secondClass* create_object()
{return new secondClass}