My question is about creating the instance a of ClassA in the constructor of ClassMain. It looks like a will go out of scope the moment the constructor finishes executing, leaving my pointer aPtr pointing to an object that is all ready for garbage collection.
Is that a problem?
And while I'm at it I might as well ask how this would be done using an initialization list. Or is there an even better way of doing this?
(This will be an unmanaged code project. I like defining ClassA a at compile time rather than using a new statement.)
Open in new windowgo in the ClassMain.h file?
I thought of putting it there, but then wondered if that meant every one who did #include ClassMain.h would be instantiating an instance of ClassA?