May 20, 2012 at 6:04pm UTC
Why do I get this error?
Line 12: 'Contact::Contact(std::string)' and 'Contact::Contact(std::string)' cannot be overloaded.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include <string>
#include <vector>
using namespace std;
#ifndef _CONTACT_H_
#define _CONTACT_H_
class Contact {
public :
Contact(std::string FirstName);
Contact(std::string LastName);
std::string getFirstName() ;
std::string getLastName() ;
std::string getNickname() ;
std::string getEmail1() ;
std::string getEmail2() ;
std::string getPhone1() ;
std::string getPhone2() ;
std::string getAddress() ;
std::string getWebsite() ;
std::string getBirthday() ;
std::string getNotes() ;
private :
std ::string firstname;
std ::string lastname;
std ::string nickname;
std ::string email1;
std ::string email2;
std ::string phone1;
std ::string phone2;
std ::string address;
std ::string website;
std ::string birthday;
std ::string notes;
};
#endif
Last edited on May 20, 2012 at 6:07pm UTC
May 20, 2012 at 6:08pm UTC
Because these two declarations
Contact(std::string FirstName);
Contact(std::string LastName);
declare the same function Contact( std::string ); The name of the parameter does not play any role in function declaration.
May 20, 2012 at 6:27pm UTC
Declare the construactor as
Contact::Contact( const std::string &FirstName, const std::string &LastName );
Or declare a default constructor as
Contact::Contact();
and also declare additional function as
1 2
vois setFirstName( const std::string &FirstName );
void setLastName( const std::string &LastName );
Last edited on May 20, 2012 at 6:32pm UTC
May 20, 2012 at 6:41pm UTC
I think you do not require semicolon after the constructor definition ends
AddressBook::AddressBook(){}
Last edited on May 20, 2012 at 6:41pm UTC
May 20, 2012 at 6:42pm UTC
It looks like addressbook.cpp was not included in the project. Also remove the semicolon after closing brace in the constructor definition.
May 20, 2012 at 6:49pm UTC
thanks so much. so now how can I create a Contact with those tokens
like Contact newContact(tokens[1], tokens[2],token[3] .... tokens[11])
each token represents one of the items. ex. first name is token[1]
and where would I include this?
Last edited on May 20, 2012 at 6:51pm UTC
May 20, 2012 at 7:22pm UTC
So, how could I now create a Contact with these tokens?