#include <iostream>
using namespace std;
template<typename T>
class InputData{
private:
T data_a;
T data_b;
void get_a(T a){data_a=a;}
void get_b(T b){data_b=b;}
};
template<typaname T>
class Arith_Unit: public InputData<T>{
public:
T add(){return data_a+data_b;}
T sub(){return data_a-data_b;}
T mul(){return data_a*data_b;}
T div(){return data_a/data_b;}
};
template<typename T>
class Logic_Unit: InputData<T>{
public:
T and(){return data_a&data_b;}
T or(){return data_a|data_b;}
T xor(){return data_a^data_b;}
};
template<typename T>
class ALUnit: public Arith_Unit<T>, Logic_Unit<T>{
private:
Arith_Unit arith;
Logic_Unit logic;
public:
ALUnit(T a, T b){
arith = new Arith_Unit();
arith.get_a(a);
arith.get_b(b);
logic = new Logic_Unit();
logic.get_a(a);
logic.get_b(b);
}
T op(int choice) {
switch(choice){
case 0:
return arith.add();
case 1:
return arith.sub();
case 2:
return arith.mul();
case 3:
return arith.div();
case 4:
return logic.and();
case 5:
return logic.or();
case 6:
return logic.xor();
}
}
};
int main(){
return 0;
}
Comments
Leave a comment