What will be the result of different calls of class and structure methods?
#include <iostream>

class A {
public:
  virtual A &Get() {
    std::cout << "A";
    return *this;
  }
};

struct B : A {
  B &Get() {
    std::cout << "B";
    return *this;
  }
};


int main(int, char *argv[]) {
  B b;
  A &a1(b), a2(a1), *a3(&a2), *a4(&a1);
  b.Get();
  a1.Get();
  a2.Get();
  a3->Get();
  a4->Get();
}

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести