@rybic

Почему не перегружается оператор присваивания (программа даже не работает)?

main.cpp:
#define __CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#include "classic.h"
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#include <iostream>
void bravo(const cd& disk);
int main()
{
	cd c1("b\0", "c\0", 14, 35.5);
	classic c2 = classic("p\0", "c\0", "a\0", "p\0", 2, 57.17);
	cd* pcd = &c1;
	c1.report();
	c2.report();
	pcd->report();
	pcd = &c2;
	pcd->report();
	bravo(c1);
	bravo(c2);
	classic copy;
	copy = c2;
	//copy.report();
	return 0;
}
void bravo(const cd& disk) {
	disk.report();
}

classic.h:
#ifndef classic
#include "cd.h"
class classic :public cd {
private:
	char cursong[20];
	char curperform[50];
	//char* cursong;
public:
	classic(const char* s1, const char* s2,const char *s3, const char * s4,int n, double x);
	virtual void report()const;
	classic();
	classic& operator=(const classic& d);
};
#endif // !classic

classic.cpp:
#define _CRT_SECURE_NO_WARNINGS
#include "classic.h"
#include <string.h>
#include <iostream>
using std::cout;
classic::classic(const char* s1, const char* s2, const char* s3, const char* s4, int n, double x):cd(s1,s2,n,x) {
	strcpy(curperform, s4);
	strcpy(cursong, s3);
}
void classic::report() const{
	cd::report();
	for (auto& x : cursong) {
		if (x == '\0') break; cout << x;
	}
	cout << "\n";
	for (auto& x : curperform) {
		if (x == '\0') break;
		cout << x;
	}
	cout << "\n";
}
classic& classic::operator=(const classic& d) {
	if (this == &d) return *this;
	strcpy(cursong, d.cursong);
	strcpy(curperform, d.curperform);
	cd::operator=(d);
	return *this;
}

Помогите, пожалуйста. (если нужны файлы cd.cpp и cd.h пишите).
Ошибки в vs:

Ошибка LNK2019 ссылка на неразрешенный внешний символ "public: __thiscall cd::cd(void)" (??0cd@@QAE@XZ)

и

Ошибка LNK1120 неразрешенных внешних элементов: 1
  • Вопрос задан
  • 97 просмотров
Решения вопроса 1
jcmvbkbc
@jcmvbkbc
"I'm here to consult you" © Dogbert

Ошибка LNK2019 ссылка на неразрешенный внешний символ "public: __thiscall cd::cd(void)" (??0cd@@QAE@XZ)

говорит о том, что не найдена реализация конструктор класса cd без параметров.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы