class **urgent~help me solve it pls

1. If classA includes a private variable n, a protected variable m, and a public variable k, and classB is derived from classA, which of these variables can be use in classB? Can n become private in classB? protected? public? How about variables m and k? does it make a difference whether derivation of classB was private, protected or public?

2. Transform the declaration
template<class T, int size = 50>
class genClass {
T storage [size];
……………………..
Void memberFun() {
…………………
If (someVar < size) {…….}
……………………..
}
};

Which uses an integer variable size as a parameter to template to a declaration of genClass, which does not include size as a parameter to template and yet allows for flexibility of the value of size. Consider a declaration of genClass’s constructor. Is there any advantage of one version over another?

3. What happen if the declaration of genClass :
class genClass {
…………………….
virtual void process1 (char) ;
virtual void process2 (char) ;
};

Is followed by this declaration of derivedClass?
class derivedClass : public genClass {
………………………….
void process1 (int) ;
int process2 (char) ;
};

Which member functions are invoked if the declaration of two pointers
genClass *objectPtr1 = &derivedClass ,
*objectPtr2 = &derivedClass ;
Is followed by these statements?
objectPtr1->process1(1000);
objectPtr2->process2(‘A’);

Last edited on
Topic archived. No new replies allowed.