Conversion from ‘Foo*’ to non-scalar type ‘Foo’ requested

From Cppsyntax

Jump to: navigation, search

You will get messages about conversion difficulties if what is on the left-hand side of an assignment equals sign is not the same as what is on the right-hand side. This particular one means that the right-hand side is a pointer, while the left-hand side is not a pointer and not a simple type. For example:

WRONG

  Foo aFoo = new Foo();   // constructors return pointers


RIGHT

  Foo *aFoo = new Foo();
Personal tools