The .h file, Logic.h:

#pragma once class Logic { public: Logic(void); ~Logic(void); Logic(bool x); bool Get(); //accessor function void Set(bool x); //mutator function bool Not(); bool And(Logic x); bool Or(Logic x); bool Nand(Logic x); bool Nor(Logic x); bool ExOr(Logic x); bool ExNor(Logic x); bool Print(); private: bool b; };

The implementation file, Logic.cpp:

#include "StdAfx.h" #include "Logic.h" Logic::Logic(void) { b = false; } Logic::Logic(bool x) { b = x; } Logic::~Logic(void) { } bool Logic::Get() { return b; } void Logic::Set(bool x) { b = x; } bool Logic::Not() { return !b; } bool Logic::And(Logic x) { return b && x.b; } bool Logic::Or(Logic x) { return b || x.b; } bool Logic::Nand(Logic x) { return !(b && x.b); } bool Logic::Nor(Logic x) { return !(b || x.b); } bool Logic::ExOr(Logic x) { return b && x.Not() || !b && x.b; } bool Logic::ExNor(Logic x) { return !(b && x.Not() || !b && x.b); } bool Logic::Print() { return b; }

...and the source file:

#include "stdafx.h" #include <iostream> #include "Logic.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) {Logic a, b, sum; cout << "Enter a value for the first bit... " << endl; cin >> //this is where variable " a " would be input cout << "Enter a value for the second bit... " << endl; cin >> //this is where variable " b " would be input. sum = a.And(b); cout << "Sum = " << sum.Print() << endl; return 0; }

As you can probably guess, I'm trying create a program that performs boolean algebra - pretty simple in itself, but I can't for the life of me figure out how to get user input. The user must input either 1 or 0. I've been toying with the Get() and Set() functions, but I can't quite seem to get it right. Build fails with errors each time. I must be completely missing something obvious, it's kind of depressing...

EDIT: Just a hint is fine too, I feel like I should know it, I've just kind of hit a wall.

This post has been edited by **Chaosnub**: 02 November 2009 - 09:11 PM