L
lovecreatesbeauty
Hello Experts,
Why static data members can be declared as the type of class which it
belongs to?
Inside a class, non-static data members such as pointers and references
can be declared as type of its own class. Non-static data members can
not be declared as type of its own class (excluding pointers and
references).
Why static data members can be declared as the type of its own class,
even though this member is not pointer or reference?
What's the consideration behind the restrictions or behavior of the
language? Thanks!
class Date{
static Date default_date;
public:
Date(int dd=0, int mm=0, int yy=0);
};
Date Date::default_date(16, 12, 1770);
-- lovecreatesbeauty
Why static data members can be declared as the type of class which it
belongs to?
Inside a class, non-static data members such as pointers and references
can be declared as type of its own class. Non-static data members can
not be declared as type of its own class (excluding pointers and
references).
Why static data members can be declared as the type of its own class,
even though this member is not pointer or reference?
What's the consideration behind the restrictions or behavior of the
language? Thanks!
class Date{
static Date default_date;
public:
Date(int dd=0, int mm=0, int yy=0);
};
Date Date::default_date(16, 12, 1770);
-- lovecreatesbeauty