drpingoo
Erfahrenes Mitglied
Hi zusammen,
Es ist eigtl eine ganz simple Aufgabe! Ist mehr für mich so ein bisschen zum ausprobieren. Aber der Compiler motzt da bei der Erstellung von Person two("Smythecraft"); und Person three("Dimwiddy", "Sam"); und ich weiss einfach nicht wieso?
Er sagt folgendes:
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall Person:erson(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (0Person@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD@Z)" in Funktion "_main".
Dazu habe ich noch eine weitere Frage, allg zu Konstruktoren. Wenn ein Konstruktor nicht initialisiert wird, wie bei "Heyyou", und ich dennoch einen Konstruktor mit einem Defaultwert wie bei Person two aufrufen möchte, würde das dann gehen? Kanns leider nicht ausprobieren, da es ja iwelche Probleme gibt.
Danke für eure Hilfe!
Es ist eigtl eine ganz simple Aufgabe! Ist mehr für mich so ein bisschen zum ausprobieren. Aber der Compiler motzt da bei der Erstellung von Person two("Smythecraft"); und Person three("Dimwiddy", "Sam"); und ich weiss einfach nicht wieso?
Er sagt folgendes:
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall Person:erson(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (0Person@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD@Z)" in Funktion "_main".
Dazu habe ich noch eine weitere Frage, allg zu Konstruktoren. Wenn ein Konstruktor nicht initialisiert wird, wie bei "Heyyou", und ich dennoch einen Konstruktor mit einem Defaultwert wie bei Person two aufrufen möchte, würde das dann gehen? Kanns leider nicht ausprobieren, da es ja iwelche Probleme gibt.
Danke für eure Hilfe!
Code:
#include <iostream>
#include <string>
using namespace std;
class Person{
private:
static const int LIMIT = 25;
string lname; //Person's last name
char fname[LIMIT]; //Person's first name
public:
Person(){lname = " "; fname[0] = '\0'; } //#1
Person(const string & ln, const char * fn="Heyyou"); //#2
//The following methods display lname and fname
void Show() const; //firstname lastname format
void FormalShow() const; //lastname, firstname format
};
void Person::Show() const{
cout << "Firstname: " << fname << " and Lastname: " << lname << endl;
}
void Person::FormalShow() const{
cout << lname << ", " << fname << endl;
}
int main(){
Person one;
Person two("Smythecraft");
Person three("Dimwiddy", "Sam");
one.Show();
cout << endl;
one.FormalShow();
two.Show();
two.FormalShow();
three.Show();
three.FormalShow();
return 0;}