0
Please see my source code !! Its not giving me the satisfying answer !! Please tell me what is the error
#include<iostream> using namespace std; class test { int a,b; public: void getdata(int x,int y ) { a=x; b=y; } int geta() { return a; } int getb() { return b; } void show() { cout<<a<<endl<<b<<endl; } }; class exam : public test { int c; public: void mul() { c=geta()*getb(); } void disp() { cout<<c<<endl; } }; int main() { test o; o.getdata(2,66); o.show(); exam x; x.mul(); x.disp(); return 0; } Output : 2 66 0
2 Réponses
0
X variable in main function :
Call the x.getdata() to assign value to its class variables
Then call the mul() and disp()
0
Thanks 😊😊