22. september 2004 - 10:48Der er
3 kommentarer og 1 løsning
constructors, copy-constructors and destructors info
Hi there! Let's start with saying that I do understand Danish, so it's not obligatory to answer in English..!-)
I would like to know a little bit about constructors, destructors and copy constructors. I'm learning from this tutorial (If I remember correctly, it's "Sam's Teach Yourself C++ In 21 Days) - and it uses these constructors, and I understand them (almost) thoroughly. It's just this one thing I'm just eager to know, how you can know when to put braces and when not to:
class SomeClass // No braces { public: SomeClass(); SomeClass(const SomeClass &); ~SomeClass(); }
class SomeClass // With braces { public: SomeClass() {}; SomeClass(const SomeClass &) {}; ~SomeClass() {}; }
Can someone give me an answer on this and help me to understand this..? Something tells me, it's not that important, but I would really like to know what I'm doing! ;-)
If they are declared like that they MUST be defined elsewhere! Probably your linker won't complain though, until you actually try to instantiate an object of the class.
hmmm... all right... if you say so =P I might be wrong, however I'm sure that I could use it without the enclosing braces once in that tutorial. But you're probably right, because I can't remember when I used it. So it could be in the start of the chapter including classes. (Just writing a class, and not actually use it)
Thank you for you response..!-)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.