Q1 PROPERTIES OF A STATIC MEMBER VARIABLE IN C++ CLASS
Q1 PROPERTIES OF A STATIC MEMBER VARIABLE IN C++ CLASS.
1 When class object is created the data of static member is same for all objects.
2 A static member is shared by all objects of the class.
3 All static data is initialized to zero when the first object is created.
4 if no other initialization is present. We can’t put it in the class definition but it can be initialized outside the class .
Q2 WHY MIGHT IT BE USEFUL TO CREAT A COPY CUNSTRUCTOR FOR C++ CLASS? EXAMPLE OF A COPY CUNSTRUCTOR FOR C++ CLASS?
copy constructor is the constructor that C++ uses to make copies of objects. It carries the name X::X(const X;), where X is the name of the class. That is, it’s the constructor of class X, which takes as its argument a reference to an object of class X. This sounds really useless, but just take a minute to explore why C++ needs such beasties. In the call to fn(), C++ passes a copy of the object and not the object itself.
EXAMPLE OF A COPY CUNSTRUCTOR
using namespace std;