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: not >>1-36 2010-05-23 3:09

>>36
While C doesn't, specific implementations for which people tend to write their code (besides libraries, most applications contain architecture-specific code) do specify things like stack layout in great detail. I've also yet to see a C compiler which doesn't use a stack, and almost all va_start/va_arg/va_end macros operate on the stack directly. Just because it doesn't have to, doesn't mean it won't. While you're programming in ANSI C, you have no right to assume those things, but once you step down and use a real implementation (or a group of real implementations), you can start very clearly making assumptions about how allocation will work, and you can confirm these by inspecting libc source code or the compiler's source code, as well as the generated assembly listing.

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