| 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
.
|
|
|
|

|
Related Articles |
|
|