标题:类和对象
取消只看楼主
FrankloveCyy
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2019-5-5
结帖率:11.11%
已结贴  问题点数:10 回复次数:1 
类和对象
#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
搜索更多相关主题的帖子: 对象 class name age object 
2019-07-08 11:17
FrankloveCyy
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2019-5-5
得分:0 
好的,非常感谢。
2019-07-08 13:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-495745-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.536088 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved