![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
===========================
#include <iostream>应该放在#include "stdafx.h"之后,要不会出错:
错误 1 error C2871: “std”: 具有该名称的命名空间不存在 c:\documents and settings\manio\my documents\visual studio 2005\projects\oh2005\oh2005\oh2005.cpp 8
错误 2 error C2065: “cout”: 未声明的标识符 c:\documents and settings\manio\my documents\visual studio 2005\projects\oh2005\oh2005\oh2005.cpp 12
#include "stdafx.h"
#include <iostream>
using namespace std;
//关于虚函数
class person
{
public:
virtual void sex() = 0;
};
//如person中sex()有函数体,为空也一样,sex(){},出错,提示:sex()已有函数体
//如person中sex()后接=0,即sex() = 0; 出错
void person::sex()
{
cout<<"kkdo";
}
class gz:public person
{
public:
void showname() {
cout<<"guozheng";
}
//void sex(){} ;
};
int main()
{
cout<<"ts\n";
person gz1;
}
Question:#include <iostream>
using namespace std;
//关于虚函数
class person
{
public:
virtual void sex() = 0;
};
//如person中sex()有函数体,为空也一样,sex(){},出错,提示:sex()已有函数体
//如person中sex()后接=0,即sex() = 0; 出错
void person::sex()
{
cout<<"kkdo";
}
class gz:public person
{
public:
void showname() {
cout<<"guozheng";
}
//void sex(){} ;
};
int main()
{
cout<<"ts\n";
person gz1;
}
virtual sex() const = 0;
与
virtual sex() = 0;
的区别?