11-23-2017, 09:08 PM
CS304 Object Oriented Programming
Assignment 2 Solution
Fall 2017
Solution:
Copy and Paste the following code in DevC++, save your file and then compile and run.
Assignment 2 Solution
Fall 2017
Solution:
Copy and Paste the following code in DevC++, save your file and then compile and run.
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
class website
{
char *name;
public:
website()
{
cout <<"Website default constructor is called\n\n";
}
website(char *Name)
{
cout <<"\nwebsite perameterized constructor is called!";
}
};
class webpage
{
double width;
double height;
public:
webpage()
{
cout << "\nWebpage default constructor is called";
}
webpage(double x, double y)
{
cout<< "\nWebpage Perameterized constructor is called!";
}
};
class links
{
char *name;
public:
links ()
{
cout << "\nlink default constructor is called";
}
links (char *Name)
{
cout << "\nlink perameterized constructor is called!";
}
};
int main()
{
webpage aweb;
links alink;
cout << endl << endl;
webpage aweb1;
links alink1;
cout << endl << endl;
webpage aweb2;
links alink3;
cout << endl;
webpage aweb11(112, 512);
links alink11("A");
website awebsite11("A");
cout << endl << endl ;
system ("pause");
return (0);
}