Static Object

Does a static object implicitly call it's contructor or does it need to be excliptlly called?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
header:
class  ImageData
{
    static ImageData TotalImageData;
    // or 
    static ImageData *TotalImageData = new ImageData();
} 

cpp:

ImageData::ImageData()
{
//set data to defaults
}

ImageData ImageData::TotalImageData;


Thanks!!
A static object's constructor is called implicity. Your hypothetical object's constructor is called when this file-scope code is executed:

ImageData ImageData::TotalImageData;

Also, a class can't have an instance of itself as a member (but it can have a pointer to an instance of itself).
Topic archived. No new replies allowed.