2016-10-08 3 views
-2

У меня есть два класса и основной. Я следовал за все, как лучше всего, как я могу найти, но все еще есть ошибкиC++ Общие ошибки Классы Конструкторы

Любая помощь идентификации ошибка будет хорошо принят

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

#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

, пожалуйста, включите в вопрос сообщения об ошибках (обычный текст, без изображения) – user463035818

+0

Если это Visual Studio, скопируйте текст сообщения об ошибке из вкладки «Вывод». 'Alt-2' – drescherjm

+3

- это ошибка копирования-вставки, или есть ли в вашем Birthday.cpp второе объявление' class Birthday'? – user463035818

ответ

0

Я использую Virtual Studio, 2015 Я нашел решение. Я просто удалил People.exe из папки отладки и снова построил проект. И это сработало. Al, поэтому подобная проблема я удалил файл, а re сделал его. Вставил тот же код и исправил проблему. Не знаю, почему

Смежные вопросы