#include<iostream>
using namespace std;
class cube
{
private:
int lengh;
int width;
public:
int geta();
void get(int a,int b)
{
lengh=a;
width=b;
}
void show()
{
cout<<lengh*width<<endl;
}
};
int main()
{
cube c1;
c1.get(4,5);
c1.show();
}
类外调用形式:
#include<iostream>
using namespace std;
class cube
{
private:
int lengh;
int width;
public:
void get(int a,int b);
void show();
};
void cube::get(int a,int b)
{
lengh=a;
width=b;
}
void cube::show()
{
cout<<lengh*width<<endl;
}
int main()
{
cube c1;
c1.get(4,5);
c1.show();
}