Problem with CPP Statement
-
Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion)
Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)SnaidiS(Semion)
-
Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion)
Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)SnaidiS(Semion)
Your declaration of the array is the problem.
Tic_Tac_Toe *PointersToNodes;
...
PointersToNodes=new Tic_Tac_Toe[9];It is not an array of pointers, but an array of objects. For each Tic_Tac_Toe, you are calling the constructor. try this
Tic_Tac_Toe **PointersToNodes;
...
PointersToNodes=new Tic_Tac_Toe* [9]; -
Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion)
Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)SnaidiS(Semion)
The left side of your assignment statement expects a value of type
Tic_Tac_Toe
, while your member functionbuildNewTree
returns a pointer to a value of typeTic_Tac_Toe
.
Software Zen:
delete this;
-
Your declaration of the array is the problem.
Tic_Tac_Toe *PointersToNodes;
...
PointersToNodes=new Tic_Tac_Toe[9];It is not an array of pointers, but an array of objects. For each Tic_Tac_Toe, you are calling the constructor. try this
Tic_Tac_Toe **PointersToNodes;
...
PointersToNodes=new Tic_Tac_Toe* [9]; -
Hello, I'm using Visual C++ 2003. I have a problem in my code at line 36,you can see the code here(I give you all the code of the file because I think that all the things are important):Code[^] T1 is an Tic_Tac_Toe object (the class is defined from line 5-14. pointersToNodes is a pointers array to Tic_Tac_Toe objects. and buildNewTree is a function which returns adress of a Tic_Tac_Toe object(line 78). at line 36 it writes me the following error:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tic_Tac_Toe *' (or there is no acceptable conversion)
Thats it. Can you please tell me please why the error occurs and how to solve/fix it? Thank you all!:)SnaidiS(Semion)
Do you by any chance take the same C++ class as SwatiPathania? (see post just beneath yours) :rolleyes:
-- Torn from tomorrow's headlines
-
You are very much welcome. It is nice to here a thankyou around here for a change ;0)
-
The left side of your assignment statement expects a value of type
Tic_Tac_Toe
, while your member functionbuildNewTree
returns a pointer to a value of typeTic_Tac_Toe
.
Software Zen:
delete this;
-
Do you by any chance take the same C++ class as SwatiPathania? (see post just beneath yours) :rolleyes:
-- Torn from tomorrow's headlines