If the highlighed statement is true, static object of user defined class type shouldn't call default constructor, isn't it
This(above quoted statement) is not true. You are clearly misinterpreting what the author(Lippman) said. In particular, they never said that static object of user defined type shouldn't call default constructor.
is my interpretation of the statement wrong
Yes your interpretation is wrong, this is because:
The default constructor is used automatically whenever an object is default or value initialized. Default initialization happens When we define nonstatic variables (§ 2.2.1, p. 43) or arrays (§3.5.1, p. 114) at block scope without initializers
The above quoted statement doesn't mean/imply that static
data members cannot use default constructor.
For example, consider the following snippet:
#include<iostream>
struct Name
{
Name()
{
std::cout<<"default constructor called"<<std::endl;
}
Name(std::string pname): name(pname)
{
std::cout<<"converting constructor called"<<std::endl;
}
std::string name;
};
struct Test
{
//lets give this class two static data member
static Name myName;
static Name myAnotherName;
};
//definition of static member in exactly one translation unit
Name Test::myName; //this will use Name's default constuctor
Name Test::myAnotherName("some name"); //this will use Name's converting constructor
int main(){
Test t;
return 0;
}
The output of the above program is:
default constructor called
converting constructor called
As shown in the above example, static
data members can be constructed using default constructor. Also, you can even initialize the static
data member using some other constructor, say using the converting constructor as shown above.
If you want to know what static
data members means you can refer to this and for nonstatic
data members you can refer to this
.