GeometryHomework3.cpp(192) : error C2143: syntax error : missing ';' before '->' GeometryHomework3.cpp(193) : error C2181: illegal else without matching if GeometryHomework3.cpp(194) : error C2143: syntax error : missing ';' before '->' GeometryHomework3.cpp(195) : error C2181: illegal else without matching if GeometryHomework3.cpp(196) : error C2143: syntax error : missing ';' before '->' GeometryHomework3.cpp(197) : error C2181: illegal else without matching if GeometryHomework3.cpp(198) : error C2143: syntax error : missing ';' before '->' GeometryHomework3.cpp(199) : error C2181: illegal else without matching if GeometryHomework3.cpp(200) : error C2143: syntax error : missing ';' before '->' GeometryHomework3.cpp(201) : error C2181: illegal else without matching if GeometryHomework3.cpp(202) : error C2143: syntax error : missing ';' before '->' GeometryHomework3.cpp(224) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(229) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(230) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(235) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(241) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(247) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(248) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(254) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(255) : error C2143: syntax error : missing ';' before '.' GeometryHomework3.cpp(256) : error C2143: syntax error : missing ';' before '.' |
Square* s = new Square(token);
is supposed to be in the scope of if.
|
|
I think, for example, Square* s = new Square(token); is supposed to be in the scope of if. |
|
|
s->print();
((Square*)shapes[j])->print();
(Square*)shapes[j]->print();
left of '->print' must point to class/struct/union/generic type type is 'void *' |
left of '->print' must point to class/struct/union/generic type type is 'void *' |
casting the void pointers in the shapes array to the correct type |
printSquare((Square*)shapes[j]);
?
casting the void pointers in the shapes array to the correct type
like you said, but how to do that?
((Square*)shapes[j])->print();
. You first post doesn't have any printSquare() function. But if you prefer to get rid of the print() methods and use global functions then there's no problem.You create an uninitialized pointer and use that to make calculations. This will make your program crash.
, you are right, there is warning for it in the compiler, I delete all those uninitialized pointer, also delete all the a->
, they shouldn't be there. Because I couldnt make program work b4, I added them there....