Пробовал читать ответы на другие вопросы, но ни один из них не помог мне.
//Equipment.h
#pragma once
class Equipment {
//...
};
//Display.h
#pragma once
class Display :public Equipment { //here is the error
public:
Display(int id, int price, int year);
};
//Display.cpp
#pragma once
#include "Display.h"
#include "Equipment.h"
Display::Display(int id=0, int price=0, int year=0) {
int arr[3 + 1] = { id, price, year };
//Equipment(int id, int price, int year);
}
//Printer.h and .cpp are very similar
//in composition to Display.h and .cpp
//error is in a similar position too
//source.cpp
#include<iostream>
using namespace std;
#include "Printer.cpp"
#include "Display.cpp"
Я действительно не знаю, куда поместить включаемый файл базового класса Equipment.h. Пытался вставить его в исходный код и подумал, что это сработает, если я вставлю его первым, нет.
Попытался поместить включаемый файл в оба производных заголовка, появилась другая ошибка, относящаяся к «уже определенному в Display.obj».
Все файлы заголовков и cpp должны существовать, и я понятия не имею, как разместить включаемые файлы.