erreur undefined reference to
Bonjour
Je commence le c++ et je developpe sur une virtualbox avec debian
J'ai l'erreur suivante lors de la compilation
Code:
1 2 3 4
| g++ testapi.cpp -o output
/usr/bin/ld: /tmp/cciw7NXm.o: in function `main':
testapi.cpp:(.text+0xd9): undefined reference to `ApiAres::getAllZone()'
collect2: error: ld returned 1 exit status |
mon fichier api.cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| //Api.cpp
#include "api.hpp"
//constructeur
ApiAres::ApiAres(string url, string port)
{
this->url = url;
this->port = port;
};
// std::string Api::getAllZone()
void ApiAres::getAllZone() {
cout << "Simulating getting all zones..." << endl;
}; |
mon fichier api.hpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| //Api.hpp
#include <iostream>
using namespace std;
class ApiAres
{
private:
string url;
string port;
public:
//constructeur
ApiAres(string url, string port) {
cout << "url : " << url << " port : " << port << endl;
};
void getAllZone();
// std::string getAllZone();
}; |
mon fichier de test tesapi.cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| //testapi.cpp
#include <iostream>
#include "api.hpp"
int main()
{
std::string url = "https://tyradex.vercel.app/api/v1/pokemon/246";
std::string port = "";
ApiAres apiBdd(url,port);
apiBdd.getAllZone();
//std::cout << apiBdd.getAllZone() << std::endl;
return 0;
} |
auriez vous une idées svp ?
Merci