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

  Generate the tables attach the primary key and foreign key

Generate the tables attach the primary key and foreign key

  How to store ten floating-point values into vector

How to store ten floating-point values into vector. Write down a program that declares a vector of ten floating-point values

  Write c program ''myls'' that functions like unix command ''ls''

Write C program 'myls' that functions like unix command 'ls'.

  Write proper sequence in design of a video rental database

Write proper sequence in design of a video rental database

  Description of problems and business impacts

Description of problems and business impacts

  Write the code used in a for loop

Write the code used in a for loop

  What is green computing and green communication technology

What is Green Computing and Green Communication technology.

  What are prospect trends for healthcare informatics

What are prospect trends for healthcare informatics.

  How to use ms access and create a database

How to use MS Access and create a database

  Program to evaluate case statement

Program to evaluate case statement

  What occurs in an infinite loop

What occurs in an infinite loop? Create your own Repeat-until repetition arrangement.

  Write a java program that creates an array of integers

Write a java program that creates an array of integers

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