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 it returns to me is LNK2019. I have searched for this error and understood nothing. My doubt is also on how the file . h associates to the file classeID.cpp. Anyway just know that I know nothing rsrs...
Thus, the term used is not to compile
.h
, it is only included in the source that imports it Verbatim. I will look here for an answer that talks a little about the C/C compilation process++– Jefferson Quesado
Read a little more about how the C processor works is how the CPP works in that reply
– Jefferson Quesado
Works well in Codeblocks, it’s even Linker configuration in Visual Studio
– Isac
This other answer may direct you better: https://stackoverflow.com/q/19886397
– Jefferson Quesado
@Isac I believe that the
classID.cpp
is not being compiled– Jefferson Quesado
It is capable yes, it has to confirm that the solution is compiling and linking all the files
– Isac
After_, which objects files are generated? Object file has extension
.obj
in Visual Studio (already in gcc are the.o
)– Jefferson Quesado
Put the whole code, including line and all, preferably copy the whole log, just so we can know what’s missing
– Guilherme Nascimento