In: Computer Science
In Object Oriented Programming, classes represent abstractions of real things in our programs. We must quickly learn how to define classes and develop skills in identifying appropriate properties and behaviors for our class. To this end, pick an item that you work with daily and turn it into a class definition. The class must have at least three properties/data fields and three functions/behaviors (constructors and get/set functions don’t count). Do not pick examples from the textbook and do not redefine a class already defined by a classmate. Use proper C++ syntax to present your class.
#include
using namespace std;
class Computer
{
private:
string name;
int RAM;
double processor_speed;
public:
Computer() // default constructor
{
this->name = "";
this->RAM = "";
this->processor_speed =
"";
}
Computer(string name,int RAM,double processor_speed)
// argument constructor
{
this->name = name;
this->RAM = RAM;
this->processor_speed =
processor_speed;
}
void print()
{
cout<<"Computer Name :
"<
};
int main() {
Computer c("Intel Core",4,2.93);
c.print();
return 0;
}
Output:
Computer Name : Intel Core RAM : 4 GB Processor Speed : 2.93 Ghz