#include<iostream.h>
#include<conio.h>

class  citizen
{
private:
      const char name[25];
      char nationality[25];

public:
	citizen()   //first constructor with no parameter
		{


	 name="Farhan";
	 nationality="PAkistani";
		}
	     citizen(char a, char b)//second constructor
		{
		name=a;
		nationality=b;
		}

      ~citizen()   // destructor
		{
		cout<<"\n Destructor called";
		}

     void display()
		{
		cout<<name;
		cout<<"\n"<<nationality;
		}
};


void main()
{
clrscr();
citizen a;

}

The output should be the following
Farhan
Pakistani

Mark
australian


Whare
Farhan
pakistani
are the initialized agaubst tge constructor with no parameter

Mark
Australian
are the initialized vaues against the constructor with to parameter mark
australian

You never call the constructor that takes parameters with "mark" "australian".

You never call the display() method

Does it even compile?

main returns int not void returning void is undefined behaviour.

#
this'll work out...:icon_cool:

void main()
#
{
#
clrscr();
#
citizen a;
a.display();
citizen b("mark","australian");
b.display();
#
 
#
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.