#ifndef
#define
#include <iostream>
using namespace std;
class print {
public:
print();
~print();
void DoPrint();
};
#endif
#include "print.h"
print::print() {
cout << "print::print()" << endl;
}
print::~print() {
cout << "print::~print()" << endl;
}
void print::DoPrint() {
cout << "print::DoPrint()" << endl;
}
#ifndef
#define
#include <iostream>
#include "print.h"
using namespace std;
class computer {
public:
computer();
~computer();
void DoCpu();
print Print;//电脑组合打印机,尽量多用组合,少用继承
};
#endif
#include "computer.h"
computer::computer() {
cout << "computer::computer()" << endl;
}
computer::~computer() {
cout << "computer:~:computer()" << endl;
}
void computer::DoCpu() {
cout << "computer::DoCpu() " << endl;
}
#include "computer.h"
#include "print.h"
int main() {
computer Computer;
Computer.DoCpu();
//组合,电脑组合打印
Computer.Print.DoPrint();
return 0;
}