Implement a class called Vehicle. a) A class named Vehicle b) Two private data members: brand (string), model (string), price (int). c) Accessors and Mutators function for brand, value and price. Use following main() to test your class. int main(){ Vehicle a; a.setBrand("BMW"); a.setModel("X5"); a.setPrice(60000); cout<
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Q1: Implement a class called Vehicle.
a) A class named Vehicle
b) Two private data members: brand (string), model (string), price (int).
c) Accessors and Mutators function for brand, value and price.
Use following main() to test your class.
int main(){
Vehicle a;
a.setBrand("BMW");
a.setModel("X5");
a.setPrice(60000);
cout<<a.getBrand()<<endl; // print BMW
cout<<a.getModel()<<endl; // print X5
cout<<a.getPrice()<<endl; // print 60000
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images