Wednesday, August 8, 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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...