Question: Fix Nyble.h and Nyble.cpp Nyble.h: #ifndef NYBLE _ H #define NYBLE _ H class Nyble { public: Nyble ( ) ; Nyble ( const Nyble&
Fix Nyble.h and Nyble.cpp
Nyble.h:
#ifndef NYBLEH
#define NYBLEH
class Nyble
public:
Nyble;
Nybleconst Nyble&;
Nyble& operatorconst Nyble&;
~Nyble;
Nybleunsigned int value;
Nyble operatorconst Nyble& other const;
friend Nyble operatorconst Nyble& nyble, unsigned int num;
friend Nyble operatorunsigned int num, const Nyble& nyble;
Nyble& operatorconst Nyble& other;
Nyble operator;
Nyble operatorint;
Nyble operatorint shift const;
Nyble operator~ const;
Nyble operator const;
operator unsigned int const;
unsigned char getData const;
private:
Do not change this data
unsigned char data;
;
#endif
End of File
Nyble.cpp:
#include "Nyble.h
Nyble::Nyble
data ;
Nyble::Nybleconst Nyble& other
data other.data;
Nyble& Nyble::operatorconst Nyble& other
if this &other
data other.data;
return this;
Nyble::~Nyble
Nyble::Nybleunsigned int value
data staticcastvalue & xF;
Nyble Nyble::operatorconst Nyble& other const
Nyble result;
result.data staticcastdata other.data & xF;
return result;
Nyble operatorconst Nyble& nyble, unsigned int num
Nyble result;
result.data nybledata num & xF & xF;
return result;
Nyble operatorunsigned int num, const Nyble& nyble
return nyble num;
Nyble& Nyble::operatorconst Nyble& other
data staticcastdata other.data & xF;
return this;
Nyble Nyble::operator
data staticcastdata & xF;
return this;
Nyble Nyble::operatorint
Nyble temp this;
this;
return temp;
Nyble Nyble::operatorint shift const
Nyble result;
shift ;
result.data staticcastdata shiftdata shift & xF;
return result;
Nyble Nyble::operator~ const
Nyble result;
result.data staticcast~data & xF;
return result;
Nyble Nyble::operator const
Nyble result;
result.data staticcastdata & xF;
return result;
Nyble::operator unsigned int const
return staticcastdata ;
unsigned char Nyble::getData const
return thisdata;
End of File
An error will occur if the test code below is executed simultaneously using the above two codes.
NybleAddOptest.cpp:
#include UnitTestConfiguration.h
#include "Nyble.h
TESTNybleAddOp, TestConfig::ALL
#if NybleAddOp
Nyble A;
Nyble B;
Nyble C;
CHECK AgetData;
CHECK BgetData;
CHECK CgetData;
C A B;
CHECK AgetData;
CHECK BgetData;
CHECK CgetData;
Nyble D;
Nyble E;
D E;
CHECK DgetData;
CHECK EgetData;
Nyble F;
Nyble G;
G F ;
CHECK FgetData;
CHECK GgetData;
Nyble H;
Nyble I;
I H;
CHECK HgetData;
CHECK I.getData;
#endif
TESTEND
End of File
NybleSpecialOpstest.cpp:
#include UnitTestConfiguration.h
#include "Nyble.h
TESTNybleSpecialOps TestConfig::ALL
#if NybleSpecialOps
Nyble E;
unsigned int MonkeyVal;
MonkeyVal E;
CHECKMonkeyVal ;
CHECKEgetData;
#endif
TESTEND
End of File
Output:
NybleAddOptest.cpp: error C: 'operator : overloaded functions have similar conversions
NybleAddOptest.cpp: error C: : overloaded functions have similar conversions
The problem has not been resolved at all.
The code given as the correct answer is the same as the existing code.
Is there a way to fix Nyble.h and Nyble.cpp to get both tests through at the same time without causing that error?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
