[C++]명품 C++ 프로그래밍 실습문제 9장 5번
[C++]명품 C++ programming 실습문제 9장 5번
명품 C++ 프로그래밍실습문제/연습문제 /C++
#include <iostream>
#include <string>
using namespace std;
class AbstractGate {
protected:
bool x,y;
public:
void set(bool x, bool y){this->x =x; this->y=y;}
virtual bool operation()=0;
};
class ANDGate :public AbstractGate{
public:
bool operation(){
return x&y;
}
};
class XORGate :public AbstractGate{
public:
bool operation(){
return x^y;
}
};
class ORGate: public AbstractGate{
public:
bool operation(){
return x||y;
}
};
int main(){
ANDGate andGate;
XORGate xorGate;
ORGate orGate;
andGate.set(true,false);
orGate.set(true,false);
xorGate.set(true,false);
cout.setf(ios::boolalpha); //불린 값을 true or false 문자열로 출력할것을 지시
cout << andGate.operation() << endl;
cout << orGate.operation() << endl;
cout << xorGate.operation() << endl;
return 0;
};
'C++' 카테고리의 다른 글
[C++] 명품 C++ 프로그래밍 실습문제 9장 8번 (0) | 2023.01.14 |
---|---|
[C++] 명품 C++ 프로그래밍 실습문제 9장 7번 (0) | 2023.01.14 |
[C++] 명품 C++ 프로그래밍 실습문제 9장 4번 (0) | 2023.01.14 |
[C++] 명품 C++ 프로그래밍 실습문제 9장 오픈챌린지/openchallenge (0) | 2023.01.14 |
[C++] 명품 C++ 프로그래밍 실습문제 8장 9번 (0) | 2023.01.13 |