I am stuck with this unary operator~
overloading part. This is my code:
Header
#ifndef NYBLE_H
#define NYBLE_H
class Nyble
{
public:
// insert your code here
Nyble()=default;
Nyble(const Nyble& n);
Nyble& operator=(const Nyble& n);
explicit Nyble(unsigned char d);
~Nyble();
Nyble operator~(const Nyble& rhs) const;
unsigned char getData();
private:
// Do not change this data
unsigned char data;
};
Source
Nyble Nyble::operator~(const Nyble&rhs) const
{
char unsigned temp=rhs.data
temp= static_cast<unsigned char>(~temp);
return Nyble(temp);
}
Is this correct? If not, what is the correct form?