Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Overload the binary XOR operator ^ . Overload the binary AND operator & . Overload a COMBO combination of AND , XOR to change it
Overload the binary XOR operator
Overload the binary AND operator &
Overload a COMBO combination of AND XOR to change its behavior.
o Instead of doing the binary operations do a three element addition.
o a & b c a b c
Overload a COMBO combination of XOR, AND to change its behavior.
o Instead of doing the binary operations do a three element subtraction.
o a b & c a b c
Do not ADD any files to the project
No free functions do all overloading inside classes as methods
Binary
#ifndef BINARYH
#define BINARYH
struct Binary;
struct XOR;
struct AND;
struct COMBO;
struct COMBO;
struct Binary
Cannot modify these operators
Binary;
Binaryunsigned int x;
Binaryconst Binary &r;
~Binary;
Binary operator const Binary &r;
add modify methods here:
HINT: you might need to delete the next three methods
start doing your proxy with a empty Binary class
easier than trying to refactor...
XOR operator const Binary& r const;
AND operator & const Binary& r const;
operator unsigned int const;
Data: do not add or modify the data
unsigned int x;
;
#endif
End of File
#include "Binary.h
#include "AND.h
#include "XOR.h
#include "COMBOh
Binary::Binary
thisx ;
Binary::Binaryunsigned int x
thisx x;
Binary::Binaryconst Binary &r
thisx rx;
Binary::~Binary
Binary Binary::operator const Binary &r
thisx rx;
return this;
XOR Binary::operator const Binary& r const
return XORthis r;
AND Binary::operator & const Binary& r const
return ANDthis r;
Binary::operator unsigned int const
return thisx;
End of File
AND
#ifndef ANDH
#define ANDH
struct Binary;
struct XOR;
struct AND;
struct COMBO;
struct COMBO;
struct AND
ANDconst Binary& a const Binary& b;
operator Binary const;
operator unsigned int const;
private:
unsigned int result;
;
#endif
End of File
#include "AND.h
#include "Binary.h
#include "COMBO.h
Add methods here:
AND::ANDconst Binary& a const Binary& b
: resultax& bx
AND::operator Binary const
return Binaryresult;
AND::operator unsigned int const
return result;
End of File
XOR
#ifndef XORH
#define XORH
forward declaration
struct Binary;
struct XOR;
struct AND;
struct COMBO;
struct COMBO;
struct XOR
XORconst Binary& a const Binary& b;
operator Binary const;
operator unsigned int const;
private:
unsigned int result;
;
#endif
End of File
#include "XOR.h
#include "Binary.h
Add methods here:
XOR::XORconst Binary& a const Binary& b
: resultax bx
XOR::operator Binary const
return Binaryresult;
XOR::operator unsigned int const
return result;
End of File
COMBO
#ifndef COMBOH
#define COMBOH
struct Binary;
struct XOR;
struct AND;
struct COMBO;
struct COMBO;
struct COMBO
TODO
;
#endif
End of File
#include "COMBO.h
#include "Binary.h
TODO
End of File
COMBO
#ifndef COMBOH
#define COMBOH
struct Binary;
struct XOR;
struct AND;
struct COMBO;
struct COMBO;
struct COMBO
TODO
;
#endif
End of File
#include "COMBOh
#include "Binary.h
TODO
End of File
Should see something like this sample codes:
Binary bxa;
Binary bx;
Binary bBinary;
unsigned int bValue;
Normal
bBinary b b;
bValue b b;
bBinary b & b;
bValue b & b;
Binary ax;
Binary ax;
Binary ax;
Binary aBinary;
unsigned int aValue;
Combo
aBinary a & a a;
aValue a & a a;
Binary cxF;
Binary cx;
Binary cx;
Binary cBinary;
unsigned int cValue;
Combo
cBinary c c & c;
output :
bxa
bx
bBinary b bxc
bValue b bxc
bBinary b & bx
bValue b & bx
ax
ax
ax
aBinary a & a ax
aValue a & a ax
cxF
cx
cx
cBinary c c & cx
cValue c c & cx
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started