cs201 Assignment No.3
Simply copy this code and paste in Dev C++. Save it by your id and submit it.๐
#include <iostream>
#include <string>
using namespace std;
class Laptop
{
private:
string Brand, Processor;
int Ram, hardDrive;
public:
Laptop()
{
cout<<"Default Constructor Called... \n";
Brand = "None";
Processor = "None";
Ram = 0;
hardDrive = 0;
}
void setBrand(string b)
{ Brand = b; }
void setProcessor(string p)
{ Processor = p; }
void setRam(int r)
{ Ram = r; }
void sethD(int hd)
{ hardDrive = hd; }
string getBrand()
{ return Brand; }
string getProcessor()
{ return Processor; }
int getRam()
{ return Ram; }
int getHD()
{ return hardDrive; }
Laptop(string theBrand, string theProcessor, int theRam, int thehardDrive)
{
cout<<"Parameterized Constructor Called...\n";
Brand = theBrand;
Processor = theProcessor;
Ram = theRam;
hardDrive = thehardDrive;
}
};
int main()
{
Laptop l;
cout<<"\nBrand : "<<l.getBrand()<<"\nProcessor : "<<l.getProcessor()<<"\nRam : "<<l.getRam()<<"\nHard Drive : "<<l.getHD()<<"\n\n";
Laptop l2("dell", "i5", 4, 500);
cout<<"\nBrand : "<<l2.getBrand()<<"\nProcessor : "<<l2.getProcessor()<<"\nRam : "<<l2.getRam()<<"\nHard Drive : "<<l2.getHD()<<"\n";
system("pause");
}
Don't forget to Bookmark our page. Thanks for Visiting
Post a Comment Blogger Facebook
Warmly Thanks for commenting. We will reply you soon