David Kravets
#include <iostream>
using namespace std;
struct A{
std::string path;
A(const std::string& val){
this->path = val;
std::cout << "constructor string" << std::endl;
}
};
struct B : public A {
A a;
B() : a("123"){
std::cout << a.path << std::endl;
}
};
int main() {
B b;
return 0;
}
/*
stdout:
constructor base
constructor string
123
*
Оберните код в теги: 3 символа ` до и после кода (в случае одиночной конструкции достаточно 1 ` с обеих сторон). Спасибо!