Rectangle area hackerrank solution in c++
C++
#include <iostream>
using namespace std;
/*
* Create classes Rectangle and RectangleArea
*/
class Rectangle{
protected:
int width;
int height;
public:
virtual void display() const{
cout<< width <<' ' << height << endl;
}
};
class RectangleArea : public Rectangle {
public:
void display() const override {
cout << (width * height) << endl;
}
void read_input(){
cin >> width >> height;
}
};
int main()
{
/*
* Declare a RectangleArea object
*/
RectangleArea r_area;
/*
* Read the width and height
*/
r_area.read_input();
/*
* Print the width and height
*/
r_area.Rectangle::display();
/*
* Print the area
*/
r_area.display();
return 0;
}
Also in C++:
- Title
- new c++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- c++ how to add something at the start of a vector
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- c++ lettura file
- Category
- C++
- Title
- c++ not greater than
- Category
- C++
- Title
- string to number in c++
- Category
- C++
- Title
- pair c++
- Category
- C++
- Title
- two sum problem in c++
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- multiset c++
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- body parser
- Category
- C++
- Title
- c++ find object in vector by attribute
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- split string at index c++
- Category
- C++
- Title
- converting char to int in c++
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- count a character in a string c++
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- single line if c++
- Category
- C++
- Title
- dijkstra c++ geeksforgeeks using set
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- qt graphics scene map cursor position
- Category
- C++
- Title
- in c, is class uppercase or lowercase
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- c++ delete dynamically allocated array
- Category
- C++
- Title
- how to run c++ file mingw cmd
- Category
- C++
- Title
- deque c++
- Category
- C++
- Title
- registering a new QML type
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- phph date
- Category
- C++
- Title
- built in popcount c++
- Category
- C++
- Title
- string length c++
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- c++ class member initialization
- Category
- C++
- Title
- Check if a Number is Odd or Even using Bitwise Operators
- Category
- C++
- Title
- c++ stream string into fiel
- Category
- C++
- Title
- knapsack
- Category
- C++
- Title
- fast input output in c++
- Category
- C++
- Title
- array syntax in c++
- Category
- C++
- Title
- c++ over load oprator to print variable of clas
- Category
- C++
- Title
- opperanf >> c++
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- how to sort in descending order c++
- Category
- C++
- Title
- namespaces c++
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- bellman ford algorithm cp algorithm
- Category
- C++
- Title
- char to string c++
- Category
- C++
- Title
- can you use rand to read in from an external file inc++
- Category
- C++
- Title
- how to compare lower case character to uppercase cpp
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- lisy stl C++
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- removing repeated characters in a string c++
- Category
- C++
- Title
- binary serach in c++
- Category
- C++
- Title
- cin.fail()
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- find in set of pairs using first value cpp
- Category
- C++
- Title
- rick astley - never gonna give you up
- Category
- C++
- Title
- sleep system function linux c++
- Category
- C++
- Title
- c++ write new file
- Category
- C++
- Title
- variable sized arrays hackerrank solution in c++
- Category
- C++
- Title
- rosrun actionlib_msgs genaction.py
- Category
- C++
- Title
- inheritance protected in c++
- Category
- C++
- Title
- how to find the size of a character array in c++
- Category
- C++
- Title
- how to import getline in c++
- Category
- C++
- Title
- swapo algorit
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- mao two drivers c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- reference function in c++
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- change int to string cpp
- Category
- C++
- Title
- sort function in vector c++ stl
- Category
- C++
- Title
- matrix eigen c++ example
- Category
- C++
- Title
- hashset in c++
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- vector stl c++
- Category
- C++
- Title
- cannot jump from switch statement to this case label c++
- Category
- C++
- Title
- double ended queue in c++ stl
- Category
- C++
- Title
- c++ do you not inherit constructor
- Category
- C++
- Title
- Operator overloading in C++ Programming
- Category
- C++
- Title
- c++ char print fixed
- Category
- C++
- Title
- accumulate in cpp
- Category
- C++
- Title
- binary tree deletion
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- inconsequential meaning
- Category
- C++
- Title
- insert at position in vector c++
- Category
- C++