<span style="font-size:18px;">C++ 类的使用(定义一个类,里面包含两个数据元素和一个成员函数,并输出数据元素较大值)</span>
#include <iostream>
class Max
{
private:
int a;
int b;
public:
int print(int &a,int &b)
{
return a>b?a:b;
}
};
int main(void)
{
using std::cout;
using std::cin;
using std::endl;
int a,b;
cout << "please input numbers: " << endl;
cin >> a >> b ;
Max max;
int maxo = max.print(a,b);
cout << "the max number is:" << maxo << endl;
return 0;
}