/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
basic_content/virtual/set3/copy_consrtuct.cpp
29 строк
574 B
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
#include <iostream> using namespace std; class Base { public: }; class Derived : public Base { public: Derived() { cout << "Derived created" << endl; } Derived(const Derived &rhs) { cout << "Derived created by deep copy" << endl; } ~Derived() { cout << "Derived destroyed" << endl; } }; int main() { Derived s1; Derived s2 = s1; // Compiler invokes "copy constructor" // Type of s1 and s2 are concrete to compiler // How can we create Derived1 or Derived2 object // from pointer (reference) to Base class pointing Derived object? return 0; }