Advertisement
TwITe

Untitled

Dec 25th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. protected:
  6.     int i;
  7. public:
  8.     A() = default;
  9.     A(int a) {
  10.         i = a;
  11.         cout  << "A's constructor called" << endl;
  12.     };
  13. };
  14.  
  15. class B: A {
  16. private:
  17.     A a_object(10); // Вместо создания initializer лист для инициализации объекта, почему нельзя сделать так?
  18. public:
  19.     B() = default;
  20. };
  21.  
  22. int main() {
  23.     B object();
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement