I am trying to learn class design, I tried to run the following code, but the compiler complains the ambiguous call to overloaded function, anyone could help me? Thanks
Here is the code
Header file
#ifndef RQ10_2_H_
#define RQ10_2_H_
class Person
{
private:
static const int LIMIT=25;
char lname;
char fname[LIMIT];
public:
Person();
Person(const char *ln); //person 1
Person(const char * ln, const char * fn="Heyyou");
void Show(); //firstname lastname format
void FormalShow(); //lastname, firstname format
};
#endif
Class implementation file
#include <iostream>
#include "RQ10_2.h"
Person::Person(const string * co)
{
using namespace std;
cout<<"constructor with only first name called.\n";
strcpy(lname,co);
char fname[0]='\0';
}
Person::Person(const string * co1, const char * co2)
{
using namespace std;
cout<<"constructor with both first name and last name called.n";
strcpy(lname,co1);
strcpy(fname,co2,24);
fname[24]='\0';
}
void Person::Show()
{
using std::cout;
using std::endl;
cout<<fname<<" "<<lname<<endl;
}
void Person::FormalShow()
{
using std::cout;
using std::endl;
cout<<lname<<","<<fname<<endl;
}
Main function
#include <iostream>
#include "RQ10_2.h"
int main()
{
using std::cout;
using std::endl;
Person person2("Smythecraft");
person2.Show();
Person person3("Dimwiddy","Sam");
person3.Show();
person3.FormalShow();
return 0;
}