   question about classes
  There is something that i dont understand about classes.when you make a class why do you have to end it with a curly brace and a semicolon. I every since i saw this it has plague my mind.don''t curly brace and semicolon both mean the samething...  
  Not really. Curly braces are used to encompass code blocks, and semi-colons are used to end statements. The curly braces encompass the definition of the class, and the semi-colon tells the compiler that this is the end of the definition. ;  It is a place where you can create instances of that classs.  Example: class Test{public:    void Foobar();private://Stuff here} TestObject;This creates a TestObject object of class Test.  It's not normally used this way since you usually create the objects when you need them (ie Test TestObject).  But declaring them this way can have its uses ( private embedded classes for example ).  -------Andrew PlaneShift - A MMORPG in development. [edited by - acraig on February 4, 2004 5:15:52 PM];quote:Original post by porthios  Curly braces are used to encompass code blocks...Statement blocks, which are themselves statements. That''s why for, if and while bodies can be either single statements or statement blocks.The semicolon is redundant. It''s just a failure of the language syntax. I mean, why aren''t there semicolons at the end of other statement blocks? ;  acraig is correct.It is because something can legally come after the closing brace of a type definition. So, without the semicolon it would be impossible to determine when the statement ends.   Human beings, by changing the inner attitudes of their minds, can change the outer aspects of their lives.William James (1842 - 1910);quote:Original post by Oluseyi  quote:Original post by porthios   Curly braces are used to encompass code blocks...Statement blocks, which are themselves statements. That''s why for, if and while bodies can be either single statements or statement blocks.The semicolon is redundant. It''s just a failure of the language syntax. I mean, why aren''t there semicolons at the end of other statement blocks?   Isn''t it much more an artifact of the "old" C way of declaring struct types? You writestruct SomeType {  int SomeMember;} varOfType;  Now, to more in line with the C syntax while providing a Better Way of doing things, C++ introduced an implicit typedef that would make "SomeType a;" equivalent to "struct SomeType a;". As acraig said, the semicolon actually ends a declaration, not a statement. Since classes are just structs with members being private by default (structs default to public), the seemingly odd notation follows. ;  Yes, you''re right Shadowdancer. My mistake. 