Given the declarations
#include <iostream.h>
class Gromitz
{
int g;
public:
Gromitz(int i=0) { g = i; }
Gromitz operator+(const Gromitz& gr) const
{
return Gromitz(g + gr.g);
}
bool operator==(const Gromitz& x) const
{
return g == x.g;
}
ostream& operator<<(ostream &str) const
{
str << g;
return str;
}
int val() const { return g; }
};
Gromitz a,b(5);
void f(Gromitz g);
Say which are valid (will compile), and which are invalid (will not compile).
- a = 10;
- a += b;
- cout << b;
- a == 7;
- f(b);