类和对象
#include<iostream>#include<string>
class Human
{
public:
string name;
int age;
void IntroduceSelf()
{
cout<<"I am" + name <<"and am";
cout<<age<<"yeas old"<<endl;
}
};
int main()
{
//An object of class Human with atttibute name as "Adam
Human firstMan;
firstMan.name="Adam";
firstMan.age= 30;
//An object of class Human with attribuete name as "Eve"
Human firstWoman;
firstWoman.age=28;
firstMan.IntroduceSelf();
firstWoman.IntroduceSelf();
} 这是编译器出现的报错,代码都是照的书上代码敲的,也没有单词敲错啊,大神们能告诉我原因吗?编译器用的 Dev-C++ 5.11