用正确的反义词组命名具有互斥意义的变量或相反动作的函数等

用正确的反义词组命名具有互斥意义的变量或相反动作的函数等。

例如: int minValue; int maxValue;

int SetValue(…); int GetValue(…);

 

 1 #include <iostream>
 2 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 // ex_class类接口定义
 6 class ex_class
 7 {
 8 private:
 9     int iv;
10     double dv;
11 public:
12     ex_class(void);
13     ex_class(int n,double x);
14     void set_ex_class(int n,double x);
15     void show_ex_class(char*);
16 };
17 
18 //定义ex_class类的构造函数
19 ex_class::ex_class(void):iv(1), dv(1.0) { }
20 ex_class::ex_class(int n,double x):iv(n), dv(x) { }
21 
22 //定义ex_class类的成员函数
23 void ex_class::set_ex_class(int n,double x)
24 {
25     iv=n;
26     dv=x;
27 }
28 void ex_class::show_ex_class(char *name)
29 {
30     cout<<name<<": "<<endl;
31     cout <<"iv=" <<iv<< endl;
32     cout <<"dv=" <<dv<< endl;
33 }
34 
35 int main(int argc, char** argv) {
36         ex_class obj1;
37     obj1.show_ex_class("obj1");
38     obj1.set_ex_class(5,5.5);
39     obj1.show_ex_class("obj1");
40 
41     ex_class obj2(100,3.14);
42     obj2.show_ex_class("obj2");
43     obj2.set_ex_class(2000,1.732);
44     obj2.show_ex_class("obj2");
45     return 0;
46 }

 

转载于:https://www.cnblogs.com/borter/p/9413413.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值