Operator Overloading
What is wrong with my code snippet?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
#include <ostream>
#include <iomanip>
using namespace std;
class X
{
int Number;
public:
void operator+();
X(int);
};
void operator+(X,X);
void operator+(X,double);
int main()
{
X a;
cout << a+1<< setw(5) << 1+a<< endl;
return 0;
}
|
This is the error which is returned.
error: no matching function for call to ‘X::X()’
You did not declare a constructor for class X all you did was call a prototype.
Thank you, Solved.
Topic archived. No new replies allowed.