Wednesday 8 August 2018

C++ Class forward declaration drawbacks?

I want to use forward declaration of a class in my software, so I can have typedefs
and use them inside the class full declaration.




Smth like this:



class myclass;
typedef boost::shared_ptr pmyclass;
typedef std::list myclasslist;

class myclass : public baseclass
{
private: // private member declarations

__fastcall myclass();

public: // public member declarations
__fastcall myclass(myclass *Parent)
: mEntry(new myclass2())
{
this->mParent = Parent;
}
const myclass *mParent;
myclasslist mChildren;

boost::scoped_ptr mEntry;
};


so my question is:
are there any drawbacks in this method? I recall some discussion on destructor issues with forward declaration but I did not get everything out of there.
or is there any other option to implement something like this?



Thanks.



EDIT:

I found the discussion I was referring to: here

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...