fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. class A
  6. {
  7. int a,b,c; //По умолчанию private.
  8. };
  9.  
  10. class B:public A //Применили наследование и на основе класса A создали класс B
  11. {
  12. };
  13.  
  14. class C //Независимый класс
  15. {
  16. };
  17.  
  18. A obj_A; //Экземпляр класса A
  19. B obj_B; //Экземпляр класса B
  20. C obj_C; //Экземпляр класса С
  21.  
  22. void main()
  23. {
  24.  
  25. cout<<sizeof(obj_A)<<endl; //Вывели на экран размер объекта от класса A
  26. cout<<sizeof(obj_B)<<endl; //Вывели на экран размер объекта от класса B
  27. cout<<sizeof(obj_C)<<endl; //Вывели на экран размер объекта от класса C
  28.  
  29. getch();
  30. return;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:22:11: error: ‘::main’ must return ‘int’
 void main()
           ^
prog.cpp: In function ‘int main()’:
prog.cpp:29:8: error: ‘getch’ was not declared in this scope
  getch();
        ^
prog.cpp:30:2: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
  return;
  ^~~~~~
stdout
Standard output is empty