Question about structs



 DEVELOP > c-Plus-Plus > Question about structs

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 04 Jan 2006 03:38:02 PM
Object: Question about structs
Does the standard support structs have constructors?
.

User: "=?UTF-8?B?TWF0ZXVzeiDFgW9za290?="

Title: Re: Question about structs 04 Jan 2006 03:52:59 PM
wrote:

Does the standard support structs have constructors?

Yes,
Here is example copied from standard (draft, 2005-10-19):
struct X { // defines X
int x; // defines non-static data member x
static int y; // declares static data member y
X (): x (0) { } // defines a constructor of X
};
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
.

User: "mlimber"

Title: Re: Question about structs 04 Jan 2006 03:53:15 PM
wrote:

Does the standard support structs have constructors?

Yes. Structs and classes have only a few minor differences. See the
FAQ:
http://www.parashift.com/c++-faq-lite/classes-and-objects.html#faq-7.8
In addition, structs default to public inheritance, whereas classes
default to private.
Cheers! --M
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER