Error trying to compile .h files in c ++

0

The code is this:

#include "stdafx.h"
#include "classeID.h"
#include <iostream>
#include <string>

using namespace std;

int main() {
    id label("default", 0);
    cout << "Nome: " << label.getName() << "\n";
    cout << "Idade: " << label.getIdade() << "\n";
    return 0;
}

//arquivo .h----------

#ifndef classeID_H
#define classeID_H
#include <string>
using namespace std;
class id {
private:
    string name;
    int idade;
public:
    id(string n, int i);
    ~id(void);
    string getName();
    int getIdade();
private:
    void welcome();
};
#endif // !classeID_H

//arquivo de implementação da classe id(classeID.cpp)----------

#include "classeID.h"
#include <iostream>
#include <string>

using namespace std;

id::id(string n, int i) {
    welcome();
    this->name = n;
    this->idade = i;
}

id::~id(void) {
    cout << "Objeto label destruido.\n";
    system("pause > null");
}

void id::welcome(void) {
    cout << "Bem vindo\n";
}
string id::getName() {
    return name;
}

int id::getIdade() {
    return idade;
}

I use Visual Studio as IDE. The error that it returns to me is LNK2019. I already searched for this mistake and did not understand anything. My question is also how the .h file is associated with the file classID.cpp. Anyway, I only know that I know nothing ...

    
asked by anonymous 06.07.2017 / 03:39

1 answer

0

I found the problem by looking at the content link indicated by @Jefferson Quesado. The classID.h and classID.cpp files were never properly associated with the main POO.cpp file. I re-created the files within the same solution and the program compiled normally. Sorted out.

    
06.07.2017 / 20:20