⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gatewiredemo.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 CPP
字号:
#include <iostream>
using namespace std;

#include "gates.h"
#include "wires.h"

int main()
{
    Wire * in  =  new Wire();  // and-gate in
    Wire * in2 =  new Wire();  // and-gate in
    Wire * in3 =  new Wire();  // or-gate in 
    Wire * aout = new Wire();  // and-gate out
    Wire * oout = new Wire();  // or-gate out
    
    Gate * andg = new AndGate(in,in2,aout,"andgate");
    Gate * org  = new OrGate(in3,andg->OutWire(0),oout);
    cout << "attaching probes" << endl;
    Probe * p = new Probe(aout);       // attach to the and-out wire
    Probe * q = new Probe(oout);       // attach to the or-out wire

    cout << "set " << *in << " on" << endl;
    in->SetSignal(true);
    cout << "set " << *in2 << " on" << endl;
    in2->SetSignal(true);
    cout << "set " << *in << " off" << endl;
    in->SetSignal(false);
    cout << "set " << *in3 << " on" << endl;
    in3->SetSignal(true);
    return 0; 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -