You are viewing bramcohen

Mon, Nov. 30th, 2009, 01:48 pm

The reason that C++ takes so long to compile is because it allows you to instantiate classes on the stack (as against instantiating a mere pointer to the class) - the size of the class must be known at compile time, so you must give the compiler the classes' definition, as well as any class definitions on which the class is dependent on in turn, and so on. C++ programmers endevaour to minimise compilation dependencies, by the use of declarations when a full definition is unneeded (such as when you just have a pointer to the class, or are just passing it as a parameter to a function that is defined elsewhere). There is actually an idiom called "pimpl" or "chesire cat" which entails creating a facade, forwarding class that just has the public interface of the implementation, to which it is the only client - this is something I'd only use in extreme cases though. Slow compile times are a weakness of C++, to be sure.

Have you developed in C++ (as against just compiling a C++ program)? Typically, you have a debug build without compiler optimisations, which tends to speed things up considerably, especially if you're using GCC.

I don't know about Chinese, but Hebrew doesn't have uppercase or lowercase.

I'm not sure why the whole reference/pointer thing causes confusion/annoyance; references are just safer alternatives to pointers, in that they must be initialised (cannot be NULL or wild), and cannot change that which they refer to - they're an "alternative name" for the variable, not a distinct thing - they have the same memory address as the original, referenced variable (at least ostensibly). They exist to facilitate easy passing by reference to functions (no need to use pointer semantics), and to faciliate operator overloading (no need to de-reference a pointer returned by an operator, defeating the point of overloading - exploiting client's intuition about what the operator ought to mean).

No HTML allowed in subject


Notice! This user has turned on the option that logs IP addresses of anonymous posters. 

(will be screened)