菜鸟求助:编译时出现错误
我是照着书打的,编译时提示:error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
Error executing cl.exe.麻烦各位高手看下是怎么回事呢?[code=C/C++][/code]
#include<iostream>
#include<string>
using namespace std;
class person
{
private:
char *name;
public:
person(char *inputname=NULL)
{
name=new char[10];
strcpy(name,inputname);
}
person(person &p)
{
if(!p.name)
return;
int length=strlen(p.name)+1;
name=new char[length];
strcpy(name,p.name);
}
void show();
};
void person::show()
{
cout<<name<<endl;
}
void showagain(person p)
{
cout<<p.show();
}
person pass()
{
person s("li ning");
return s;
}
void main()
{
person student1("wang yang");
person student2(student1);
student1.show();
student2.show();
person student3;
student3=pass();
showagain(student3);
cin.get();
}
书上也有错误,像这个程序的string.h头文件开始就没include,是不是书上的程序什么地方打错了呢
[解决办法]
我想二楼已经说得很清楚了,顶!