Есть класс Son который наследует класс CARD, который в свою очередь наследует класс MARSH. Когда я пишу к примеру cout << (Son)So;
Пишет что нет подходящего конструктора копирования, что с моим конструктором не так?
Son(Son &z) :CARD(z)
{
n = z.n;
nd = z.nd;
na = z.na;
ntl = z.ntl;
if (z.card != NULL)
{
CARD *t5 = new CARD[z.n];
if (t5 == NULL)
{
exit(1);
}
for (int i = 0; i < n; i++)
t5[i] = z.card[i];
card = t5;
}
else
card = NULL;
if (z.dep != NULL)
{
COUNTOFTRAIN *t1 = new COUNTOFTRAIN[z.nd];
if (t1 == NULL)
{
exit(1);
}
for (int i = 0; i < nd; i++)
t1[i] = z.dep[i];
dep = t1;
}
else
dep = NULL;
if (z.arr != NULL)
{
MARSH *t2 = new MARSH[z.na];
if (t2 == NULL)
{
exit(1);
}
for (int i = 0; i < na; i++)
t2[i] = z.arr[i];
arr = t2;
}
else
arr = NULL;
if (z.tr != NULL)
{
traintrain *t3 = new traintrain[z.ntl];
if (t3 == NULL)
{
exit(1);
}
for (int i = 0; i < ntl; i++)
t3[i] = z.tr[i];
tr = t3;
}
else
tr = NULL;
}
Класс 1:
class MARSH
{
public:
string pointofdeparture;
string arrivalpoint;
TIME time;
int trainnumber;
MARSH()
{
pointofdeparture = "";
arrivalpoint = "";
time.hours = NULL;
time.minutes = NULL;
trainnumber = NULL;
}
MARSH(MARSH &z)
{
pointofdeparture = z.pointofdeparture;
arrivalpoint = z.arrivalpoint;
time.hours = z.time.hours;
time.minutes = z.time.minutes;
trainnumber = z.trainnumber;
}
};
Класс 2:
class CARD:public MARSH
{
public:
MARSH pole;
string surname;
string init;
string type;
double cost;
CARD() :MARSH()
{
surname = "";
init = "";
type = "";
cost = 0;
}
CARD(CARD &z) :MARSH(z)
{
surname = z.surname;
init = z.init;
type = z.type;
cost = z.cost;
}
Класс 3:
class Son :public CARD
{
protected:
CARD *card;
int n;
COUNTOFTRAIN *dep;
int nd;
MARSH *arr;
int na;
traintrain *tr;
int ntl;
public:
Son():CARD(), card(NULL), n(0), dep(NULL), nd(0), arr(NULL), na(0), tr(NULL), ntl(0) {}
~Son()
{
if (card != NULL) delete[] card;
if (dep != NULL) delete[] dep;
if (arr != NULL) delete[] arr;
if (tr != NULL) delete[] tr;
}
Son(Son &z) :CARD(z)
{
n = z.n;
nd = z.nd;
na = z.na;
ntl = z.ntl;
if (z.card != NULL)
{
CARD *t5 = new CARD[z.n];
if (t5 == NULL)
{
exit(1);
}
for (int i = 0; i < n; i++)
t5[i] = z.card[i];
card = t5;
}
else
card = NULL;
if (z.dep != NULL)
{
COUNTOFTRAIN *t1 = new COUNTOFTRAIN[z.nd];
if (t1 == NULL)
{
exit(1);
}
for (int i = 0; i < nd; i++)
t1[i] = z.dep[i];
dep = t1;
}
else
dep = NULL;
if (z.arr != NULL)
{
MARSH *t2 = new MARSH[z.na];
if (t2 == NULL)
{
exit(1);
}
for (int i = 0; i < na; i++)
t2[i] = z.arr[i];
arr = t2;
}
else
arr = NULL;
if (z.tr != NULL)
{
traintrain *t3 = new traintrain[z.ntl];
if (t3 == NULL)
{
exit(1);
}
for (int i = 0; i < ntl; i++)
t3[i] = z.tr[i];
tr = t3;
}
else
tr = NULL;
}
Оборудование для ресторана: новинки профессиональной кухонной техники
Частный дом престарелых в Киеве: комфорт, забота и профессиональный уход
Читал другие темы с этим вопросом, но у меня не получается перевестиПрограмма работает, но вот выводит неправильно
Написал граф через классы на списку смежностиПомогите написать корректный алгоритм поиска мостов