C++ C++;对“Class::Ctor';

C++ C++;对“Class::Ctor';,c++,class,oop,header,C++,Class,Oop,Header,我有这个错误 在函数“int main()”中:| 未使用的变量“Bobi” 在函数“main”中:| 对“Student::Student()”的未定义引用| ||==生成失败:1个错误,1个警告(0分钟,1秒))===| 你能帮我解决这个问题并检查我的方法声明吗 这是我的main.cpp #include <iostream> #include "Student.h" using namespace std; int main() { Student *Bobi

我有这个错误

在函数“int main()”中:| 未使用的变量“Bobi” 在函数“main”中:|

对“Student::Student()”的未定义引用|

||==生成失败:1个错误,1个警告(0分钟,1秒))===|

你能帮我解决这个问题并检查我的方法声明吗

这是我的main.cpp

    #include <iostream>
#include "Student.h"
using namespace std;

int main()
{
    Student *Bobi= new Student();

    return 0;
}
#include "Student.h"
#include <iostream>
using namespace std;
Student::Student()
{
}
Student::~Student()
{
}
#包括
#包括“Student.h”
使用名称空间std;
int main()
{
学生*Bobi=新学生();
返回0;
}
这是我的标题

    #ifndef STUDENT_H
#define STUDENT_H
#include <string>

class Student
{
    public:
        Student();
        virtual ~Student();
        std::string getName()
        {
            return this->name;
        }
        void setName(std::string name)
        {
            this->name=name;
        }
        int getNumber()
        {
            return this->number;
        }
        void setNumber(int number)
        {
            this->number=number;
        }
        std::string getSurname()
        {
            return this->surname;
        }
        void setSurname(std::string surname)
        {
            this->surname=surname;
        }
        double setDiploma1(double diploma1)
        {
            return this->diploma1;
        }
        void getDiploma1()
        {
            this->diploma1=diploma1;
        }
        double setDiploma2(double diploma2)
        {
            return this->diploma2;
        }
        void getDiploma2()
        {
            this->diploma2=diploma2;
        }
        double setIzpit1(double izpit1)
        {
            return this->izpit1;
        }
        void getIzpit1()
        {
            this->izpit1=izpit1;
        }
        double setIzpit2(double izpit2)
        {
            return this->izpit2;
        }
        void getIzpit2()
        {
            this->izpit1=izpit2;
        }
        double Bal(double setDiploma1,double setDiploma2,double setIzpit1,double setIzpit2)
        {
            double bal=setDiploma1+setDiploma2+setIzpit1+setIzpit2;
            return bal;
        }
    protected:
    private:
        int number;
        std::string name;
        std::string surname;
        double diploma1;
        double diploma2;
        double izpit1;
        double izpit2;
};

#endif // STUDENT_H
\ifndef学生
#定义学生
#包括
班级学生
{
公众:
学生();
虚拟~Student();
std::string getName()
{
返回此->名称;
}
void setName(std::string name)
{
此->名称=名称;
}
int getNumber()
{
返回此->编号;
}
无效集合编号(整数编号)
{
这个->数字=数字;
}
std::string getname()
{
返回此->姓氏;
}
void setSurname(标准::字符串姓氏)
{
这->姓=姓;
}
双套文凭1(双文凭1)
{
返回此->1;
}
void get1()
{
这->文凭1=文凭1;
}
双套文凭2(双文凭2)
{
返回此->2;
}
void get2()
{
这->文凭2=文凭2;
}
双组izpit1(双组izpit1)
{
返回此->izpit1;
}
void getIzpit1()
{
这->izpit1=izpit1;
}
双组izpit2(双组izpit2)
{
返回此->izpit2;
}
void getIzpit2()
{
这->izpit1=izpit2;
}
双Bal(双SETPLICA1、双SETPLICA2、双SETPIT1、双SETPIT2)
{
双bal=SETPLICA1+SETPLICA2+setIzpit1+setIzpit2;
返回bal;
}
受保护的:
私人:
整数;
std::字符串名;
std::字符串姓氏;
双文凭1;
双文凭2;
双izpit1;
双izpit2;
};
#endif//STUDENT\u H
Student.cpp

    #include <iostream>
#include "Student.h"
using namespace std;

int main()
{
    Student *Bobi= new Student();

    return 0;
}
#include "Student.h"
#include <iostream>
using namespace std;
Student::Student()
{
}
Student::~Student()
{
}
#包括“Student.h”
#包括
使用名称空间std;
学生::学生()
{
}
学生::~Student()
{
}

完全删除Student.cpp文件,然后在main中使用一些set get运行。快跑


它应该会起作用。看student.cpp是否应该头文件bjt您甚至不需要它jusr在头文件中的析构函数中定义构造函数。bc虚拟使用是错误的

编译此文件时使用的生成文件或命令是什么?如何构建项目?是否确实使用
Student.cpp
源文件生成?它必须在IDE中的项目中,而不仅仅是在磁盘上的目录中。它在我的IDE中的我的项目中。我构建它,然后运行它。不要在尝试构建时谈论您当前的错误,但是为什么您的
set
函数没有任何参数?您将类成员设置为自身。。。有点奇怪,不是吗?