fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A
  6. {
  7. protected:
  8. int a;
  9. private:
  10. float b;
  11. public:
  12. double c;
  13. A(int x,float y,double z)
  14. {
  15. a=x;
  16. b=y;
  17. c=z;
  18.  
  19. }
  20.  
  21. };
  22. class B: public A
  23. {
  24. public:
  25. B(int x,float y,double z): A(x,y,z)
  26. {
  27.  
  28. }
  29.  
  30. };
  31.  
  32. class C: public B
  33. {
  34. public:
  35. C(int x,float y,double z): B(x,y,z)
  36. {
  37.  
  38. }
  39.  
  40. };
  41. main(){
  42. cout<<obj.a<<endl;
  43. cout<<obj.b<<endl;
  44. cout<<obj.c<<endl;
  45. cout<<obj.c+obj.a+obj.b<<endl;
  46.  
  47. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:42:7: error: ‘obj’ was not declared in this scope
 cout<<obj.a<<endl;
       ^~~
stdout
Standard output is empty