Private base class function declared public in derived class

Assignment Help Computer Engineering
Reference no: EM133239

Question

class Computer {
public:
void retail Price(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;
}

This question asks about how function calls to retailPrice() are evaluated.

a. Explain which version of manufactureCost() is used in the call cibmPtr-> retailPrice() and why.

b. If the virtual keyword is omitted from the declaration of manufacture Cost in derived class IBMComputer, preceding code will still compile without error and execute. Will manufacture Cost be implemented as a virtual function in class IBMComputer? Use your knowledge of how C++ is implemented to clarify why or
why not.

c.It is possible for private base-class function to be declared public in derived class. Does this conflict with subtyping principles? Elucidate why or why not in a few words.

Reference no: EM133239

Questions Cloud

What is the memory operations dominate execution time : What is  the memory operations dominate execution time
Advantages and disadvantages of implementing a dfs : Advantages and disadvantages of implementing a DFS
Enterprise application that integrates the erp concept : Presentation Server, Application Server, Database Server, Software application Architecture, SAP approach to a traditional Information system, benefits and drawbacks of SAP, different SAP application modules, automation and process of enterprise appl..
Tcp connections experience data segment loss : TCP connections experience data segment loss
Private base class function declared public in derived class : Private base class function declared public in derived class
How to explain capacity of the queue : How to explain capacity of the queue
Graph a flowchart or pseudocode : Graph a flowchart or pseudocode
Efficient kitchen supervision depends on the organization : Hygiene in food production, Nutrition in food service, Hors d'oeuvres, Aperitifs, Aging of meat, Méthode Champenoise, some cooking methods are only applicable to some types of food
How to exchange the floating point number : How to exchange the floating point number

Reviews

Write a Review

Computer Engineering Questions & Answers

  What is the goal to exercises in the bluej textbook

What is the goal to exercises in the BlueJ textbook? For the remains of the course, you will answer the questions posed by BlueJ textbook-you will not require downloading an additional worksheet and filling it in as you did for first four units.

  Write pseudo code - program and draw flow chart

Write pseudo code, program and draw flow chart for programs

  Problem on encryption using a one-round version of des

Problem on encryption using a one-round version of DES.

  Write down program for a bank account

Write down program for a bank account

  Explain examples of type of knowledge industry

Explain examples of type of knowledge industry

  What factors in computer design would affect the decision

What factors in computer design would affect the decision.

  Examine how computer forensics investigations pertain to law

Examine how computer forensics investigations pertain to law

  How can a relation be organized in mass storage

How can a relation be organized in mass storage.

  Accessing and reading a mouse

Accessing and reading a mouse

  Ip cameras to improve security for devry university

IP cameras to improve security for DeVry University.

  Implement needham-schroeder protocol using python

Implement Needham-Schroeder protocol using python

  How to run and modify marie program

How to run and modify marie program Include a decision before storing and outputing result. If  value of the result is not positive (so zero or negative), set  Result value to the value ZERO (0)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd