C++: given the following class interface containing static members . 4. Given th
ID: 3578364 • Letter: C
Question
C++: given the following class interface containing static members
.
Explanation / Answer
a) statClass::statMbr = 50;
this means we need to initialize data varable in the format given below:
className::varableName = value;
(b) for static class-name::function-name
class items { public: static int count;
void getdata(int a) { count++;
}
};
int items:: count;
int main()
{
items a,b;
a.getdata(100);
b.getdata(200);
}
(c)
d) Only one copy of member function is created for the entire class and is shared by all the objects of that class.Hence it
A static function can have access to only other static members (functions or variables) declared in the same class.
A static member function can be called using the class name the class name(instead of objects)
e) No, Because static members are called without object name.They are called by class name.