我有这个错误按摩
在功能' 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;
}
这是我的标题
#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
Student.cpp
#include "Student.h"
#include <iostream>
using namespace std;
Student::Student()
{
}
Student::~Student()
{
}
答案 0 :(得分:0)
完全删除Student.cpp文件,然后使用main中的set get运行。现在运行
它应该工作。看看student.cpp应该标题bjt你甚至不需要它jusr定义构造函数在析构函数的头文件中你有.bc虚拟使用是错误的