//AhmedWafaa Typing
#include <iostream>
using namespace std;
 class nameage {
 	public:
 		//declaring variables 
 		string name;
 		int age;
 		//constructor without parameter
 	nameage() {
 		name = "none";
 	    age = 0;
 	}
 	//constructor with string parameter
 	nameage(string name1) {
 		name = name1;
 		age = 0;
	 }
	 //constructor with int parameter
	nameage(int age1) {
		name = "none";
		age = age1;
	}
	//constructor with string and int parameter
	nameage(string name1 , int age1) {
		name = name1;
		age = age1;
	}
	//display function for passed string and int
	void display() {
		cout << " name is:  " << name << " and " << "age is  " << age << endl;
	}
 };
 int main() {
 	//calling first constructer
 	nameage name;
 	name.display();
 	//calling second constructer
 	nameage name1("ahmed");
 	name1.display();
 	//calling third constructer
 	nameage name2(23);
 	name2.display();
 	//calling fourth constructer
 	nameage name3("ahmed" , 23);
 	name3.display();
 	return 0;
 }

Leave a comment

Your email address will not be published. Required fields are marked *