I have a class defined called extBlock.
I then make an instance of that class with this
extBlock mainBlock = new extBlock(1, 1024);
I get this error:
error C2440: ‘initializing’ : cannot convert from ‘extBlock *’ to ‘extBlock’
Can anyone help me with why I am getting this error.
I have seen examples online of declaring it like this with a pointer
extBlock *mainBlock = new extBlock(1, 1024);
But if I do it this way it does not let me call the functions of mainBlock
This isn’t C#:
new extBlockreturns a pointer to anextBlock, and you’re trying to assign that pointer to a value type (which would be an incompatible cast).What you want to write here is
And the reason you couldn’t call methods on the second code snippet was probably because you were using the
.operator instead of the->(arrow) operator needed to dereference a pointer.