Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ pointer vs. non-pointer

Name: Anonymous 2010-05-22 19:54

Sup /prog/

C++, if I make my own class, lets just say class cShitHead

cShitHead dave * new cShitHead( "dave" );
dave->PrintName();

or

cShitHead dave( "dave" );
dave.PrintName();

I myself like the pointer notation better. However, which one is more efficient and better on memory? and why?

Name: Anonymous 2010-05-23 0:21

In the first case memory is allocated on the HEAP.

In the second case memory is allocated on the STACK.

It's the same amount of memory in both cases.  The memory on the heap needs to be de-allocated manually, while the memory on the stack is released automatically when the function returns.

Name: Anonymous 2010-05-23 0:27

>>26
is sepples really that retarded? does it really specify implementation details like that?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List