注册 登录
编程论坛 C++教室

关于纯虚函数的问题。。。求高手看下。。

_莫荣。 发布于 2012-12-12 22:35, 312 次点击
#include "stdafx.h"
#include <string>
using namespace std;

class Human  
{
public:
    string work;
    Human();
    ~Human();
    virtual string work() = 0;

};

class Student:public Human
{
public:
    Student(string a);
    string work();
};



    virtual string work() = 0
这句话错在那里了error C2040: 'work' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (void)' differs in levels of indirection from 'class std::basic_string<char,struct std::char_traits<char>,cl

这个错误我没见过。。。按照书上操作的呀。。
2 回复
#2
wuxia1111112012-12-12 23:59
#include "stdafx.h"
#include <string>
using namespace std;
命名空间一会儿是,"stdafx.h",下面又
#include <string>
using namespace std;
是不行的啊!楼主试试啊!改为
#include "stdafx.h"
#include <string.h>去掉using namespace std;

#3
rjsp2012-12-13 08:32
Human中有一个成员变量work,又有一个成员函数work
1