CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <vector>
using namespace std;
class AND{
public:
void setInput(bool i){
in.push_back(i);
}
bool getOutput(){
bool tmp = (in[0]) && (in[1]);
return tmp;
}
private:
vector<bool> in;
bool out;
};
int main() {
AND gate1;
AND gate2;
gate1.setInput(1);
gate1.setInput(1);
gate2.setInput(1);
gate2.setInput(gate1.getOutput());
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run