这是报的错误:
2010\project\test6\test6\test6_1.cpp(18): error C2059: 语法错误:“字符串”
1>d:\vs 2010\project\test6\test6\test6_1.cpp(18): error C2238: 意外的标记位于“;”之前
1>d:\vs 2010\project\test6\test6\test6_1.cpp(28): error C2065: “m_strAge”: 未声明的标识符
1>d:\vs 2010\project\test6\test6\test6_1.cpp(29): error C2761: “int teacher::getAge(void)”: 不允许成员函数重新声明
1>d:\vs 2010\project\test6\test6\test6_1.cpp(30): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>d:\vs 2010\project\test6\test6\test6_1.cpp(36): error C2664: “teacher::setAge”: 不能将参数 1 从“const char [4]”转换为“int”
这是代码:
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
class teacher{
public:
// void setName(String name);
//String getName();
void setAge(int age);
int getAge();
private:
//String("m_strName");
int("m_strAge");
};
/*void teacher::setName(String name)
{ m_strName=name;}
String teacher:: getName();
{ return m_strName;}*/
void teacher::setAge(int age)
{ m_strAge= age;}
int teacher::getAge();
{ return m_strAge;}
int main(void){
teacher tea;
//tea.setName="kongzi";
tea.setAge("100");
//cout<<getName()<<endl;
cout<<getAge()<<endl;
system("pause");
return(0);
}