Hi,

My understanding was that all static data members in a class needs to be initialized.

In one of the programs, I forgot to initialize a static composite data member (what i mean by composite type is a a class type) and the compiler didn't throw any error.

It did throw an error when i didn't initialize a static primitive data member

Code:
class A
{};

class B
{
    public:
        static void f1();
    private:
        static int n1;
        static A a1;
};


void B :: f1()
{
    n1 = 10; //throws an error
    A a2;
    a2 = a1; //does not throw an error though it is not initialized
}

int main()
{
    return(0);
}
error:
Code:
hyper71: singleton> g++ test.cpp -o test
/tmp/cciEM614.o: In function `B::f1()':
test.cpp:(.text+0x6): undefined reference to `B::n1'
collect2: ld returned 1 exit status

Questions:
========
1) Are the static composite (class type) data members initialized using their default constructors ? And is that the reason why the compilers don't throw an error.

2) The error thrown is "undefined reference to `B::n1'". Not sure i fully understand the error message, I thought it should have thrown an error related to not initializing.

3) Is class data type referred as composite data types ? - not sure if there is another term for this ...

Thanks,
Muthu