void retailPrice(void)
{
int p = 2 * manufactureCost();
printf(“$ %d \ n”, p); // Print p
}
private:
virtual int manufactureCost(void)
{return 1000; }
};
class IBMComputer: public Computer
{
private:
virtual int manufactureCost(void) {return 1500;}
};
int main(void)
{
Computer *cPtr = new Computer();
IBMComputer *ibmPtr = new IBMComputer();
Computer *cibmPtr = new IBMComputer();
cPtr->retailPrice();
ibmPtr->retailPrice();
cibmPtr->retailPrice();
return 0;
}
If the virtual keyword is omitted from the declaration of manufactureCost in the derived class IBMComputer, the preceding code will still compile without errorandexecute.Will manufactureCost be implemented as a virtual function in class IBMComputer? how C++ is implemented to explain why or why not.
HI EVERY BODY PLEAAAASE HELP ME!!!
Please format the code you posted, by wrapping it in triple backticks. -> `
can you help me?
Обсуждают сегодня