Declaring Pointers/Passing Data
Code:
Stock* newStock;
newStock= new Stock(SN,Dn,CS,US,UP,MS);
newStock->Print();
Here im declaring a pointer of type Stock called newStock. Then sending the data to the stock class and saving it to my pointer.
I run the print method here as a way of checking if all has gone well.
I have used similiar ways of doing this in past and never had any problems. This seems strange to me.
I get these errors...
Error: mainapp.cpp(189,17):Undefined symbol 'newStock'
Error: mainapp.cpp(190,21):Type name expected
Error: mainapp.cpp(190,21):Statement missing ;
So...
1. Is what im doing a standard way of doing things? or am i doing something inherantly wrong?
2. Why is it telling me its undefined when i am defining it in that very piece of code.
I think its something regarding the 'newStock= new Stock(SN,Dn,CS,US,UP,MS);' that is causing the problems, especially the new. But im really stumped. Any ideas?
The stock.h and stock.cpp can be supplied if needed but i doubt its that.