• 03-15-2004
Kasatka
I recently learned operator overloading from this book I am reading and decided to test it out with some code. I can't find any errors but I get a weird output... I can't really explain. Well here's the code.

Code:

```#include <iostream> using namespace std; class ints {       int x, y, z;   public:       ints() { x = y = z = 0; }       ints(int a, int b, int c) { x = a; b = y; z = c; }       ints operator+(ints op2);       ints operator=(ints op2);       void show(); }; ints ints::operator+(ints op2) {       ints temp;       temp.x = x + op2.x;       temp.y = y + op2.y;       temp.z = z + op2.z;       return temp; } ints ints::operator=(ints op2) {       x = op2.x;       y = op2.y;       z = op2.z;       return *this; } void ints::show() {       cout << x << ", ";       cout << y << ", ";       cout << z << '\n'; } int main() {       ints a(1, 2, 3), b(10, 11, 12), c;       a.show();       b.show();       c = a + b;       c.show();       return 0; }```
The output I get is:
1, 2009376667, 3
10, -1, 12
11, 2009376666, 15
• 03-15-2004
Prelude
`ints(int a, int b, int c) { x = a; b = y; z = c; }`