I'm studying c ++ and found a problem when working with object orientation, I followed some tutorials but it did not work.
Account.h
#ifndef CONTA_H
#define CONTA_H
#include <string>
using namespace std;
class Conta{
private:
string nome;
int idade;
public:
string getNome();
int getIdade();
};
#endif // CONTA_H
Account.cpp
#include "Conta.h"
#include <string>
using namespace std;
string Conta::getNome(){
return nome;
}
int Conta::getIdade(){
return idade;
}
main.cpp
#include <iostream>
#include "Conta.h"
using namespace std;
int main()
{
Conta p;
cout << p.getNome() << endl;
return 0;
}
When I compile the code it brings me this error.
undefined reference to 'Conta::getNome()'
Obs: My Ide is CodeBlocks.