2016-10-08 2 views
-2

Ich habe eine zwei Klassen und eine Haupt. Ich habe alles so gut gefolgt, wie ich finden kann, aber immer noch Fehler habenC++ Allgemeine Fehler Klassen Konstrukteurs

Jede Hilfe identifizieren die Fehler würde gut

Error Message here

main.cpp

#include "People.h" 
#include "Birthday.h" 

int main() 
{ 
    Birthday birthObject(8, 7, 1987); 

    birthObject.printDate(); 

    People danielGadd("DanielGadd", birthObject); 

    danielGadd.printInfo(); 

    return 0; 
} 

People.h

empfangen werden
#ifndef PEOPLE_H 
#define PEOPLE_H 
#include <string> 
#include "Birthday.h" 

class People 
{ 
public: 
    People(std::string x, Birthday b); 
    void printInfo(); 

private: 
    std::string name; 
    Birthday dateOfBirth; 
}; 

#endif // PEOPLE_H 

People.cpp

#include "People.h" 
#include "Birthday.h" 

People::People(std::string x, Birthday b) 
    : name(x), dateOfBirth(b) 
{ 
} 

void People::printInfo() { 
    std::cout << name << " was born on "; 
    dateOfBirth.printDate(); 
} 

Birthday.h

#ifndef BIRTHDAY_H 
#define BIRTHDAY_H 
#include <iostream> 

class Birthday 
{ 
public: 
    Birthday(int d, int m, int y); 
    void printDate(); 
private: 
    int day; 
    int month; 
    int year; 
}; 

#endif //BIRTHDAY_H 

Birthday.cpp

#include "Birthday.h" 

Birthday::Birthday(int d, int m, int y) 
{ 
    day = d; 
    month = m; 
    year = y; 
} 


void Birthday::printDate() 
{ 
    std::cout << day << "/" << month << "/" << year << std::endl; 
} 
+2

bitte die Fehlermeldungen in der Frage (Klartext, kein Bild) – user463035818

+0

Wenn die Visual Studio kopieren Sie den Text der Fehlermeldung von der Registerkarte Ausgabe umfassen. 'Alt-2' – drescherjm

+3

ist dies ein Copy-Paste-Fehler, oder gibt es eine zweite Erklärung von' Klasse Birthday' in Ihrem Birthday.cpp? – user463035818

Antwort

0

Ich bin mit Virtual Studio 2015. Ich Lösung gefunden. Ich löschte einfach die People.exe aus dem Debug-Ordner und baute das Projekt erneut. Und es hat funktioniert. Al; so ähnlich Problem Ich habe die Datei gelöscht und neu gemacht. Habe denselben Code eingefügt und das Problem behoben. Keine Ahnung, warum