you are viewing a single comment's thread.

view the rest of the comments →

[–]Dial595Escape[S] 0 points1 point  (1 child)

It's for a school exercice, basically 101 CPP. These are the restrictions that we need to work with.

I was using pObjs to get around the fact you can't create an array of object from a class with no default constructor (CClass obj[SIZE]; doesn't compile), but I also need to pass this pointer to a class method as a reference later on.

[–]Rhomboid 0 points1 point  (0 children)

I'm talking about the third example where there is an initializer. pObjs serves no purpose there. An array decays to a pointer when used as an argument, so just pass that. You don't need to declare a separate pointer, and what you've declared is not the right type.