Re: Simple C++ variable initialization question
From: Jeff Schwab (jeffplus_at_comcast.net)
Date: 05/14/04
- Next message: Bob R: "Re: Convert old code to newer standards. [C++] (sorry)"
- Previous message: Curley Q.: "Re: [C][OT] erroneous fprintf output"
- In reply to: Brendan: "Simple C++ variable initialization question"
- Next in thread: Bhanu Ghantasala: "Re: Simple C++ variable initialization question"
- Reply: Bhanu Ghantasala: "Re: Simple C++ variable initialization question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 13 May 2004 18:10:30 -0400
Brendan wrote:
> For some reason, the most simple questin alludes me today... Perhaps
> you can shed some light for me.
>
> Say you have a class with a data member of type int or char or some
> primitive type.
>
> Very simple example, leaving out constructors, etc.
>
> class TestApp {
> public:
> int public_x;
> private:
> int private_y;
> char test_char = 'o';
> int test_int = 0;
That's illegal, unless test_char and test_int are static.
> }
>
> Do they all get defined to some initializer without being specifically
> stated, ie. public_x = 0;
It depends, but in general, the answer is no.
> Can I expect public_x to be 0 when I instantiate the class (just like
> test_int)?
No.
- Next message: Bob R: "Re: Convert old code to newer standards. [C++] (sorry)"
- Previous message: Curley Q.: "Re: [C][OT] erroneous fprintf output"
- In reply to: Brendan: "Simple C++ variable initialization question"
- Next in thread: Bhanu Ghantasala: "Re: Simple C++ variable initialization question"
- Reply: Bhanu Ghantasala: "Re: Simple C++ variable initialization question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|