Quote:Original post by Mizipzor
But I dont know what a initializer list is...
class Foo{ int i,j,k;public: Foo(int w) : i(100), j(42), k(w*100) { }};
The difference between setting the member variables in an initalizer list and setting them in the constructor's body is that with the initializer list, they are set when the object is constructed. Setting them in the class body means that first the members get default constructed (e.g. set to zero for int members), and then overwritten with the new value. For basic types it doesn't matter much, but this can quickly become very expensive. Furthermore some types cannot be assigned to (e.g. a reference or a const member), only initialized - or cannot be default constructed (e.g. class without default constructor, like Foo above) - which means you
must pass the proper parameters to the member's constructor to do the initialization. This is done with an initializer list.
Quote: i dont know about most of the stuff you wrote there. :P Im learning as I go, please bear with me ;).
Hey, I just gave you an excellent opportunity for you to at least look up what I talked about. I'd be rather disappointed (i.e. "Am I wasting my time here?") if you didn't.
Quote:Im satisfied if it just works, I dont want to add to much foreign stuff.
Quick fixes have a tendency to come back and bite you in the arse later. Better to learn how to do things correctly from the start.
Quote:Easier to learn if its... uhm... easier.
Yeah, but the Dark Side isn't more powerful, just more seductive. If you want to make programming your profession, you'd better make sure you learn do to things the Right Way™ rather than the easy way.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan