Error: 'Lecture' is not a type C++

Khi overload operator ‘=’ thì bị thông báo lỗi như trên, như thế nghĩa là sao? Khắc phục như thế nào ạ?

File Lecturer.h:

#ifndef LECTURER_H
#define LECTURER_H

#include "defination.h"
...
class Lecturer    {

    Lecturer& operator= (const Lecturer& L);
}
...
#endif

File Lecture.cpp:

//Thông báo lỗi ở đây
Lecturer& Lecturer::operator= (const Lecturer& L) {

    if(this == &L)
        return *this;

        id_number = L.id_number;
        name = L.name;
        major = l.major;
        qualification = l.qualification;
        position = l.position;
        return *this;
}

Bỏ Lecture:: đi, để lại operator= thôi xem sao?

Cũng thế thôi anh :cold_sweat:
Lâu nay cũng overload operator bình thường, tự dưng hôm nay ra cái lỗi này :cold_sweat:
Nó thông báo lỗi ngay chổ

Lecturer&

ấy

Đã #include "Lecture.h" chưa nhỉ?

full include rồi anh :cold_sweat:

Hết lỗi rồi :dizzy_face: Cũng chẳng hiểu tại sao hết lỗi luôn :dizzy_face:

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?