Write a C++ program to declare a class “box” having data members height, width and breadth. Accept this information for one object using pointer to that object. Display the area and volume of that object.
Answers
Bro this question is incorrect please correct it
Answer:
// C++ program to find the area and volume of a box
#include<iostream>
using namespace std;
class Box{
public:
int height;
int length;
int width;
};
main()
{
int height;
int length;
int width;
int volume=0;
Box b1;
b1.height=5;
b1.length=10;
b1.width=5;
volume=b1.height*b1.length*b1.width;
cout<<volume;
}
Explanation:
Object-oriented programming is the practice of using objects in programming. Transforming notions like inheritance, hiding, polymorphism, etc. from the real world into computer code is the aim of object-oriented programming. OOP's primary objective is to link the data and the functions that utilize it, making it impossible for any other function to use the code to access the data.
Code maintenance is made straightforward by object-oriented programming thanks to the usage of classes and objects. The program is easier since you don't have to write the same code more than once thanks to inheritance's ability to reuse code. Additionally, concepts like encapsulation and abstraction offer data hiding.
To learn more about encapsulation, click on the link below:
https://brainly.in/question/5423822
To learn more about Object-oriented programming, click on the link below:
https://brainly.in/question/3783924
#SPJ2