Hi! I'm having a proble with constructors. I'm supposed to write a program that has a default constructor, but also one that takes parameters. The program I wrote below is desigend to allow teh setting of age of the person, but when I compile it, I get a message saying "no appropriate default constructor available". Any help greatly appreciated. Umm, and hints on how to correctly insert my posts so code shows up better would be great as well. Thanks again!
Thanks, Bill
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
class person
{
private:
char first_name[30];
char last_name[30];
int itsAge;
public:
person(int initialAge);
~person();
void setting()
{
cout<<"Enter first_name ";
cin>>first_name;
cout<<"Enter last_name ";
cin>>last_name;
}
void printing()
{
cout<<"The first_name ";
cout<<first_name<<endl;
cout<<"The last_name ";
cout<<last_name<<endl;
}
};
//constructor of person
person::person(int initialAge) // constructor
{
itsAge=initialAge;
}
person::~person() // destructor
{}
void main()
{
int pause;
person p1;
p1.setting();
p1.printing();
cin>> pause;
}