Write and analyze the following C++ code #include using namespace std; class Animal { public: virtual...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write and analyze the following C++ code #include <iostream> using namespace std; class Animal { public: virtual void show () = 0; //Pure virtual function declaration. }; class Man: public Animal { public: void show () { cout << "Man is the part of animal husbandry " << endl; } int main() { Animal *aptr; //Base class pointer //Animal a; Man m; //derived class object creation. aptr = &m; aptr->show(); return 0; } [Paste code and program output] Write and analyze the following C++ code #include <iostream> using namespace std; class Animal { public: virtual void show () = 0; //Pure virtual function declaration. }; class Man: public Animal { public: void show () { cout << "Man is the part of animal husbandry " << endl; } int main() { Animal *aptr; //Base class pointer //Animal a; Man m; //derived class object creation. aptr = &m; aptr->show(); return 0; } [Paste code and program output]
Expert Answer:
Answer rating: 100% (QA)
The C code youve shown implements a simple example of polymorphism one of the key concepts in object... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Consider the class definitions of Programming Exercise 5 in Chapter 14,Reusing Code in C++. If you havent yet done that exercise, do so now.Then do the following: Write a program that uses standard...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
SG Company acquired 80% of Popsters Company on January 1, 2019, when the stockholders equity of Popsters consisted of: Ordinary shares, P100 par P500,000 Paid in capital in excess of par 400,000...
-
What is the difference between a man-centered approach to servant leadership and a God-centered one?
-
Refer to the Journal of Sport Behavior (2001) study of variety in exercise workouts, presented in Exercise. One group of 40 people varied their exercise routine in workouts, while a second group of...
-
Identify the mode for each of the following sets of data: a. 6, 2, 7, 6, 6, 4 b. 13, 19, 12, 13, 7, 13, 20, 13, 15 c. 4, 2, 5, 1, 2, 2, 5, 5, 3, 1, 5, 2, 6, 3 d. 40, 10, 35, 30, 10, 25, 5, 10, 15,...
-
At the beginning of the current period, Huang Co. had a balance of $100,000 in Accounts Receivable and a $7,000 credit balance in Allowance for Doubtful Accounts. In the period, it had net credit...
-
1 . What is the starting point in doing a projected discounted cash flows analysis?A . Start with the projected increase in assets.B . Start with the required interest rate.C . Start with the sale...
-
Wholesteen Dairy, Inc., produces and sells Wholesteen brand condensed milk to grocery retailers. The overall market for condensed milk is fairly flat, and theres sharp competition among dairies for...
-
Simplify. 32x4 4 5 6y z 4xy2 42z 5
-
Mr. Watson transferred the following life insurance contracts within three years of his death. Which of the following policies is not included in his gross estate? A. A life insurance contract on his...
-
A money market fund would most likely NOT contain A. Certificates of deposit. B. Commercial paper. C. Treasury bills. D. Treasury bond.
-
Which of the following statements regarding forms of health insurance is incorrect? A. In a PPO, plan participants may or may not use the PPO physician; the choice is up to the participant. B. In an...
-
Can you think of a reason why emerging market economies should be very careful when engaging in financial innovation and financial liberalization?
-
The Investment Advisers Act of 1940 establishes the foundation and regulatory framework for personal financial planning. In light of Regulatory Coverage Generally Exists for Financial Planners, but...
-
Overview Relationships, rather than simple transactions, provide the central focus in business marketing. By demonstrating superior skills in managing relationships with key customers as well as with...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19 year-old nanny $125 per week for 48 weeks during the current year. a. What is the employers portion of...
-
Modify the Vector class header and implementation files (Listings 11.13 and 11.14) so that the magnitude and angle are no longer stored as data components. Instead, they should be calculated on...
-
Write a code fragment that dynamically allocates a structure of the type described in Question 8 and then reads a value for the kind member of the structure. Data From Question 8 Devise a structure...
-
Write a three-file program based on the following namespace: namespace SALES { const int QUARTERS = 4; struct Sales { double sales[QUARTERS]; double average; double max; double min; }; // copies the...
-
Using a financial calculator, solve for the unknowns in each of the following situations. a. On June 1, 2024, Holly Golightly purchases lakefront property from her neighbor, George Peppard, and...
-
Ed owns Oak Knoll Apartments. During the year, Fred, a tenant, moved to another state. Fred paid Ed \($1,000\) to cancel the two-year lease he had signed. Ed subsequently began renting the unit to...
-
In 2017, Harry and Mary purchased Series EE bonds, and in 2023 redeemed the bonds, receiving \($500\) of interest and \($1,500\) of principal. Their income from other sources totaled \($30,000.\)...
Study smarter with the SolutionInn App