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

21st Jun 2022, 2:45 AM
Satish Kumar
2 Respostas
0
X variable in main function : Call the x.getdata() to assign value to its class variables Then call the mul() and disp()
21st Jun 2022, 4:23 AM
kris
kris - avatar
0
Thanks 😊😊
26th Jun 2022, 10:25 AM
Satish Kumar