Dear All,
If i run the code below it will let me input a name. "John Doe" but it will only print out "John".
I know how to create a char array[] and I also know how to use cin.getline but can the char array be used with the doctor methods below so I can print out the full name "John Doe" when I call cout<<Array->get_Name();
#include <iostream>
#include <stdlib.h>
#include <iostream>
#include <string.h>
using namespace std;
class doctor
{
protected:
string newname;
public:
doctor(); //constructor
virtual ~doctor();
virtual void set_Name(string itsname);
virtual string get_Name();
}; //end of class declaration
doctor::doctor()
{
}
doctor::~doctor()
{
//cout<<"Doctor Destructer called"<<endl;
}
void doctor::set_Name(string itsname){
newname=itsname;
}
string doctor::get_Name(){
return newname;
}
int main(int argc, char *argv[])
{
int i=0;
doctor* Array[5];
doctor* newdoctor;
newdoctor = new doctor();
string doctorname;
cout<<"Enter doctor name"<<endl;
cin >> doctorname;
newdoctor->set_Name(doctorname);
Array[i]=newdoctor;
cout<<Array[i]->get_Name();
system("PAUSE");
return 0;
}