Hi everyone. This is my first semester of programming, and I have been doing fairly well. I do have a question concerning OOP.
I get this error when I am trying to compile my code. I am trying to use an assignment operator to assign coordinates
error: no match for 'operator=' in 'a = (&b)->Coordinate::operator-(((Coordinate&)(&c)))'
This is what my assignment operator looks like, it seems my other overloaded operators cannot perform properly because of an error in my assignment operator. Any advice or guidance (we didn't have any about assignment and the book has nothing Deitl (blech))
Coordinate& Coordinate::operator=(Coordinate& c)
{
x = c.getX();
y = c.getY();
z = c.getZ();
return *this;
}
Oh here is a bit of the main file so you get the drift of what I am trying to do:
#include "Coordinate.h"
#include <iostream>
using namespace std;
int main()
{
Coordinate a, b( 4, 8, 16 ), c( 3, 1, -2 ), k;
cout << "Enter a graphical coordinate in the form: (x, y, z)\n? ";
cin >> k;
a = b + c;
cout << "\na = b + c:\n" << a << " = " << b << " + " << c << '\n';
a = b - c;
cout << "\na = b - c:\n" << a << " = " << b << " - " << c << '\n';
a = b * c;
cout << "\na = b * c:\n" << a << " = " << b << " * " << c << "\n\n";
if ( a != k )
{
cout << a << " != " << k << '\n';
}
cout << '\n';
a = k;
if ( a == k )
{
cout << a << " == " << k << '\n';
}