For the “Class C”: There is 2 ways for fixing this functions. Firstly fix the “yaz” and “yaz2” error in function. Secondly explain this ways.
#include <iostream>
class A {
public:
...
...
virtual void Yaz(){cout << x << y;}
void Yaz2(){cout << x << y;}
protected:
int x;
int y;
};
class B : public A {
public:
...
...
void Yaz(){cout << x << y << z;}
void Yaz2(){cout << x << y << z;}
private:
int z;
};
class C : public B {
public:
...
...
void Yaz(){cout << x << y << z << k;}
void Yaz2(){cout << x << y << z << k;}
private:
int k;
};
int main(){
A * nesne[3];
A ob1(1,2);
B ob2(3,4,5);
C ob3(6,7,8,9);
nesne[0] = &ob1;
nesne[1] = &ob2;
nesne[2] = &ob3;
nesne[0]->Yaz();
nesne[1]->Yaz();
nesne[2]->Yaz();
nesne[0]->Yaz2();
nesne[1]->Yaz2();
nesne[2]->Yaz2();
return 0;
}
For the “Class C”: There is 2 ways for fixing this functions. Firstly fix the “yaz” and “yaz2” error in function. Secondly explain this ways.
Step by step
Solved in 5 steps with 3 images