JustAnswer
SOLUTION 1:
#include
#include
using namespace std;
//Class Defination
class Person
{
public:
//Constructor
Person();
Person(string pname, int page);
//Get Methods
string get_name() const;
int get_age() const;
private:
//Class Variables
string name;
int age; // 0 if unknown
};
//Implementation of Constructors
Person::Person()
{
name = "";
age = 0;
}
Person::Person(string pname, int page)
{
name = pname;
age = page;
}
//Implementation of Get Methods.
string Person::get_name() const
{
return name;
}
int Person::get_age() const
{
return age;
}
int main()
{
//Creating Variables for Class Person using Default Constructor and Paramaterized Constructor
Person P1;
Person P2("John",21);
//Call get_name and get_age to display the values
cout ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.