Please consider the below scenario:
I have a header file and its corresponding source file:
exmp.h (Header file)
exmp.cpp (
in order to solve it (one possible way), you must make 'ptr' actually to point to a adress where a myClass objects exists. In order to exist, you have to create it, e.g.
class sampleClass
{
public:
sampleClass()
{
ptr = new myClass();
}
private:
myClass* ptr;
};
you might still consider using C++11's unique_ptr or shared_ptr instead of a raw pointer, though.