您的位置:首页 > 编程语言 > C语言/C++

C++primer plus第六版课后编程练习答案10.7

2015-11-30 16:11 477 查看
头文件
#ifndef PLORG_H_
#define PLORG_H_

const int limit=19;

class plorg
{
private:
char name[limit];
int CI;
public:
plorg(const char *str="Plorga");
void setCI(int n);
void showplorg()const;
};

#endif
#include<iostream>
#include "plorg.h"

using namespace std;

plorg::plorg(const char *str)
{
strcpy(name,str);
CI=50;
}

void plorg::setCI(int n)
{
CI=n;
}

void plorg::showplorg()const
{
cout<<"name="<<name<<endl;
cout<<"CI="<<CI<<endl;
}

#include<iostream>
#include "plorg.h"

using namespace std;

void main()
{
plorg a;
a.showplorg();
plorg b("sun");
b.showplorg();
b.setCI(30);
b.showplorg();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: