对“类名的 vtable”的未定义引用
可能的重复:
对 vtable 的未定义引用
我的文件中有一个 Student 类 - Student.h 这是它的构造函数:
class Student
{
protected:
double _id;
double _salary;
double _grade_average;
public:
Student(double id, double salary,double average):
_id(id),_salary(salary),_grade_average(average)
{}
};
然后我收到错误:
未定义对“学生 vtable”的引用
有什么问题?
这是一个 University.h 文件:
#include "Student.h"
class University : public Student
{
public:
virtual double getValue();
University(char university_id,double id, double average,double salary):
_university_id(university_id),Student(id,average,salary)
{
}
private:
char _university_id;
static double how_many;
static double sum_avg_grades;
};
Possible Duplicate:
Undefined reference to vtable
I have a class Student on the file - student.h
and this is its constructor:
class Student
{
protected:
double _id;
double _salary;
double _grade_average;
public:
Student(double id, double salary,double average):
_id(id),_salary(salary),_grade_average(average)
{}
};
And then I get the error:
undefined reference to 'vtable for Student'
What is the problem?
this is a University.h file:
#include "Student.h"
class University : public Student
{
public:
virtual double getValue();
University(char university_id,double id, double average,double salary):
_university_id(university_id),Student(id,average,salary)
{
}
private:
char _university_id;
static double how_many;
static double sum_avg_grades;
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几件事。
编译器可以使用下划线。
从它继承或使用 RTTI。 (例如虚拟析构函数)
执行。
A couple of things.
an underscore may be used by the compiler.
inheriting from it or using RTTI. (ex. a Virtual Destructor)
implementation.