"MrAsm" <email@example.com> wrote in message
On Thu, 21 Jun 2007 10:29:38 +0100, "Anthony Jones"
char * m_str;
CMyClass(char * str)
m_str = str;
// Do I need to anything with m_str
In addition to what SvenC wrote, I'd like to add that, if you use raw
pointers (like tha 'char *'), you also need to implement a copy
constructor and operator= in your class, e.g.:
// Copy ctor
CMyClass( const CMyClass & );
CMyClass & operator=( const CMyClass & );
and maybe also define your destructor to be 'virtual', to be safe e.g.
C++ has several subtle things, that you don't find in C# or
*write* lots of code (and debug it, to learn a lot also from your
I wish you a great experience learning C++!
Thanks guys for your input. I had my suspicion that the answer is
ultimately 'go read a book' however that (along with using the Web) is
and I will continue to do so. However I'm also required to maintain and
developer an ISAPI filter which up to now has be fairly basic but is
I dumbed down the example in a (failed) attempt to focus on a particular
area which so far in my studies seems somewhat ambigous. I'm hoping that
some one can say something in such that the penny will drop. Let me bring
up the detail a little (and ditch the distracting string stuff in real
I'm using CString).
My main focus is the behaviour of the return of a function. Nothing I've
read so far explains step by step what actually happens when returning a
object. Here is better example:-
//Public methods here
m_hProv = 0;
CryptAcquireContext(&m_hProv, 0, 0, PROV_RSA_FULL,
CRYPT_MACHINE_KEYSET | CRYPT_SILENT |
if (m_hProv != 0) CryptReleaseContext(m_hProv, 0);
// Other method implementations here
Now I use this class like this:-
oCryptoInA = b();
Now at guess the sequence of events on return in b is:-
Destructor of Crypto is called where this is oCryptoInA.
Nope. oCryptoInA is still alive until it leaves scope.
Destructor of Crypto is called where this is oCryptoInB.
No, actually this is called earlier. oCryptoInB is copied into a temporary
return value by the return statement, then oCryptoInB is destroyed.
DuplicateHandle to get a copy of the right-hand-side's handle. But be