Calling a virtual function in main

Hi,

I'm trying to call 2 virtual functions inside my main, and I'm calling them the same way I've been calling regular class functions...

ExampleClass randomVar = Constructor();

randomVar.classFunct();

but I'm getting an error.
Should I be doing this differently?

1
2
3
4
5
6
  Product tome = Product(bName, bType, bPrice, bQuantity);
    tome.restock(increaseStock);
    tome.setTaxRate(tax);
   
    tome.sellItem(); // these two..
    tome.print();    // .. are the virtual voids 


Thank you.
I'll leave this up in case anyone has this issue.

Only declare your virtual functions virtual such as ..

virtual void Example();

inside the .h file.

When implementing it inside your .cpp file, leave off the virtual..

void ClassEx::Example();
Topic archived. No new replies allowed.