#include<iostream>
using namespace std;
class xtime
{
public:
void set_time();
void show_time();
private:
int hour;
int minute;
int sec;
};
xtime t;
void xtime::set_time()
{
cin >> t.hour;
cin >> t.minute;
cin >> t.sec;
}
void xtime::show_time()
{
cout << t.hour << ":" << t.minute << ":" << t.sec << endl;
}
int main()
{
t.set_time();
t.show_time();
system("pause");
return 0;
}
头文件
#include<iostream>
using namespace std;
class Array_max
{
public:
void set_value();
void max_value();
void show_value();
private:
int array[10];
int max;
};
源文件1
#include"arraymax.h"
using namespace std;
void Array_max::set_value()
{
int i;
for (i = 0; i < 10; i++) cin >> array[i];
}
void Array_max::max_value()
{
int i;
max = array[0];
for (i = 1; i < 10; i++)
if (array[i] > max)max = array[i];
}
void Array_max::show_value()
{
cout << "max=" << max;
}
源文件2
#include"arraymax.h"
using namespace std;
int main()
{
Array_max arrmax{};
arrmax.set_value();
arrmax.max_value();
arrmax.show_value();
system("pause");
return 0;
}
#include<iostream>
using namespace std;
class cube
{
public:
void set_l();
void show_l();
private:
int c;
int k;
int g;
};
void cube::set_l()
{
int i;
cin >>c>>k>>g;
}
void cube::show_l()
{
cout << "vol=" << c*k*g;
}
int main()
{
cube f1{}, f2{}, f3{};
f1.set_l();
f1.show_l();
f2.set_l();
f2.show_l();
f3.set_l();
f3.show_l();
return 0;
}