/*Univercity:烟台大学
*@Class</A>计134~4
*@Author:薛富磊
*@Time:2014-4-1
*@Function:阅读程序
*@Args:
*@Return:
*/
#include<iostream>
using namespace std;
class CE
{
private:
int a,b;
int getmin()
{
return (a<b? a:b); //返回比较a,b的大小
}
public:
int c;
void SetValue(int x1,int x2, int x3)//赋值
{
a=x1;
b=x2;
c=x3;
}
int GetMin(); //调用
};
int CE::GetMin()
{
int d=getmin(); //调用赋值
return (d<c? d:c); //比较d,c大小返回
}
int main()
{
int x=5,y=12,z=8;
CE *ep;
ep=new CE; //动态分配空间
ep->SetValue(x+y,y-z,10); //相当于SetValue(17,4,10)
cout<<ep->GetMin()<<endl; //输出ep指向地址(比较4和10并返回)
CE a=*ep; //赋值为4
cout<<a.GetMin()*3+15<<endl; //计算输出27
return 0;
}
/*心得体会:
水到渠成
Unit6--problem1.2--悦
最新推荐文章于 2024-08-26 15:20:04 发布