#include<iostream>
using namespace std;
class distance //class
{
private:
int feet;
float inches;
public:
distance() :feet(0), inches(0.0) //constructor
{}
distance(int ft, float in) :feet(ft), inches(in) //constructor
{}
void getdist() //get values
{
cout << "Enter feet :";
cin >> feet;
cout << "Enter inches :";
cin >> inches;
}
void showdist() //show values
{
cout << feet << "-" << inches << endl;
}
void adddist(distance, distance); //add distance through objects
};
void distance::adddist(distance d2, distance d3) //add distance
{
inches = d2.inches + d3.inches;
feet = 0;
if (inches >= 12.0)
{
inches -= 12.0;
feet++;
}
feet += d2.feet + d3.feet;
}
int main()
{
}
我正在为家庭作业写几个课程,我希望我的班级成员函数不可能在main中调用。如果是,我希望程序退出。我如何知道何时调用我的成员函数?