1. That works if I have

ooint a = "1";
a = a + 1;

but I can't have

ooint a = "1";
ooint b = "2";
a = a + b;

Because of this:

error C2679: binary '+' : no operator defined which takes a right-hand operand of type 'class ooint' (or there is no acceptable conversion)

Wouldn't that mean you have to have another possibility for the operator overload?

2. i think i may be able to clear it up a little for you. If you want to do something like this:

ooint = int + int;

that's fine, but i think you are looking at it the wrong way. the
int + int part is the integer addition operator, which has already been defined and it returns an integer. So, this:

ooint = int + int;

really means this:

ooint = int;

because int + int returns an int. So, the overloaded = operator for the ooint class really only needs to take one argument in this case, which is an int. If you want to do this:

ooint a = "1";
ooint b = "2";
a = a + b;

what you are really doing there is adding two ooints. Have you overloaded the + operator for ooint? If so, do you have one that takes another ooint as an argument? If you don't, you can just add it:

operator +(ooint operand)
{
//whatever you wanna do
}

Hope that helps a little

3. I'm horrible at operator overloads, I know I have to do that but I don't know how.

4. That works if I have

ooint a = "1";
a = a + 1;

but I can't have

ooint a = "1";
ooint b = "2";
a = a + b;

Because of this:

error C2679: binary '+' : no operator defined which takes a right-hand operand of type 'class ooint' (or there is no acceptable conversion)

Wouldn't that mean you have to have another possibility for the operator overload?

Look dude, you have to overload an operator for every type you want to use it with, if you want to do ooint b = a + 1; then you've got to define
Code:
ooint operator + ( const ooint & lhs, int rhs )
If you want to do ooint c = a + b; then you've got to define
Code:
ooint operator + ( const ooint & lhs, const ooint & rhs )
And so on for every type you plan on using for the + operator. Unless C++ has a one step conversion from the type you want to use to the type that + is defined for, you've gotta overload again or it won't work.

5. Perfect! Thank you! That's exactly what I needed!

6. Originally posted by PorkyChop

ooint = int + int;

that's fine, but i think you are looking at it the wrong way. the
int + int part is the integer addition operator, which has already been defined and it returns an integer. So, this:

ooint = int + int;

really means this:

ooint = int;
How do I handle for that?

7. quote:
--------------------------------------------------------------------------------
Originally posted by PorkyChop

ooint = int + int;

that's fine, but i think you are looking at it the wrong way. the
int + int part is the integer addition operator, which has already been defined and it returns an integer. So, this:

ooint = int + int;

really means this:

ooint = int;
--------------------------------------------------------------------------------

How do I handle for that?
You don't, int + int is built into the compiler, so it does everything for you as long as ooint has an overloaded = operator that takes an int.

8. a = 1+2;
cout << a << endl << endl;

That outputs a heart to the screen.

[EDIT]
Oh.... I'd have to overload the =, wouldn't I?

9. a = 1+2;
cout << a << endl << endl;

That outputs a heart to the screen.
I'm surprised that even compiled, assuming that a is an ooint because the ostream operator << isn't supposed to take ooints as operands. You need a method in your ooint class, like value(), that returns the value of the integer attribute(or char array as an integer), so it would be something like this:

a = 1 + 2;
cout <<a.value() <<endl <<endl;

10. the operator << is overloaded, so cout works just fine.

Its the = that is the problem, I think.

11. the operator << is overloaded, so cout works just fine.

Its the = that is the problem, I think.
do you have an overloaded = like this?
ooint operator=( int rhs )
If you do then it's all good

12. the operator << is overloaded, so cout works just fine.

Its the = that is the problem, I think.
huh? how did you manage to overload the << operator for ostream? you can overload it for ooint, but i don't know how you would overload it for ostream...maybe i just don't know what i'm talkin about, but i doubt it. it doesn't matter how you have implemented the = operator, as long as it assigns the int value given to it to the char array correctly.

13. huh? how did you manage to overload the << operator for ostream? you can overload it for ooint, but i don't know how you would overload it for ostream...maybe i just don't know what i'm talkin about, but i doubt it. it doesn't matter how you have implemented the = operator, as long as it assigns the int value given to it to the char array correctly.
Right, you overload << for ooint to act on an ostream
Code:
ostream& operator<<( ostream& os, const ooint& stuff )
{
//print stuff
}
then you can do stuff like cout << a << endl because cout is an ostream object and a is an ooint object.

14. ok...sorry bout that. Guess I learned somethin too

15. Originally posted by Crimpy
do you have an overloaded = like this?
ooint operator=( int rhs )
If you do then it's all good
I'm not quite sure how to do this, but it makes sense. Lol, I guess I'm pathetic.