@helios Ah, no it wasn't. With that sorted though, another problem arises.
I now get this error message:
"point_test.cpp: In function ‘int main()’:
point_test.cpp:46:102: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘banfield_lab3::point’)
std::cout << "The sum of " << my_point1.get_point() << " and " << my_point2.get_point() << " is: (" << my_point1 + my_point2 << ")" << std::endl;"
Does this mean I need to convert the operator<< aswell? I already have a function that converts an instance of point to a string to display it.
1 2 3 4 5 6
|
std::string point::get_point() {
std::ostringstream strs;
strs << "(" << point::get_x() << ", " << point::get_y() << ")" << std::endl;
std::string str = strs.str();
return str;
}
|
However, if I try the following code:
1 2 3 4
|
point my_point4;
my_point4 = my_point1 + my_point2;
std::cout << "The sum of " << my_point1.get_point() << " and "
<< my_point2.get_point() << " is: (" << my_point1 + my_point2 << ")" << std::endl;
|
I get the following error message:
"point_test.o:point_test.cpp:(.text+0x4f8): undefined reference to `banfield_lab3::operator+(banfield_lab3::point const&, banfield_lab3::point const&)'
point_test.o:point_test.cpp:(.text+0x4f8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `banfield_lab3::operator+(banfield_lab3::point const&, banfield_lab3::point const&)'
collect2: error: ld returned 1 exit status"
I've done a bit more searching on google but I'm still unsure as to what exactly I'm doing wrong.