What is the output of the following C++ program? #include <iostream> #include <string> using namespace std; class Circle { public: Circle(double radius) {this->radius...
What is the output of the following C++ program?
#include [removed]
#include [removed]
using namespace std;
class Circle
{
public:
Circle(double radius) {this->radius = radius; }
void put() const {cout << "Radius = " << radius;}
private:
double radius;
};
class ColoredCircle: public Circle
{
public:
ColoredCircle(double radius, string color);
void put() const;
private:
string color;
};
ColoredCircle::ColoredCircle(double radius, string color)
: Circle(radius), color(color) {}
void ColoredCircle::put() const
{
Circle::put();
cout << " Color = " <[removed]put();
cout <[removed]put();
cout << endl;
return 0;
}
Modify the program so that the put function is virtual. What is the output after that change? Does Java allow both virtual and nonvirtual methods? If not, which does it allow? Rewrite this program in Java and identify at least four differences between the programs in the two languages.
13 years ago
5
Answer(0)
Bids(0)
other Questions(10)
- what is pie
- what is the relative humidity of a kilogram of air at 25g that contains 20 g of water vapor
- when have a concentric circle and vz is a tangent and vy is a diameter of larger circle, find...
- gilgamesh and enkidu were
- I NEED ACCOUNTING HELP ASAP!
- Computer Networking
- Organizational Behavior
- $60 Bonus Given ...I need help with a report that includes: A short introduction to the case study (http://www.paramecium.org/~leendert/publications/nluug1992.pdf) A...
- Finance
- help