October 3rd, 2012, 06:54 AM
Cannot convert type to type* error
I'm having a problem with my code.
I have an array: Atom* atoms
and I'm trying to put a member of the array in another array:
and it gives me a compilation error "cannot convert 'Atom' to 'Atom*'
why is that?
October 3rd, 2012, 07:21 AM
Because array[ i ] and atoms[ j ] do not have compatible types.
According to the information you provided, atoms[ j ] is a value of type Atom;
according to what I can deduce from the compiler message, array[ i ] is an object of type pointer to Atom.
The rules of C do not allow you to assign an Atom to a pointer.
I guess the declaration of array was something like
October 3rd, 2012, 09:20 AM
And I was guessing that atoms was declared as Atom *atoms;
OP needs to reveal to us the actual declarations for atoms and for array and put an end to these guessing games of his.
Last edited by dwise1_aol; October 3rd, 2012 at 02:24 PM.