Config.h
:
#ifndef CONFIG_H
#define CONFIG_H
class Config {
public:
static int GetDefult();
};
#endif //CONFIG_H
Config.cpp
:
#include "Config.h"
int Config::GetDefult(){
return 1;
}
main.cpp
:
#include "Config.h"
#include<iostream>
using namespace std;
int main()
{
cout << Config::GetDefult() << endl;
}
When my main file is linking, it prompts undefined references:
/tmp/ccD7rrRH.o: In function `main':
main.cpp:(.text+0x5): undefined reference to `Config::GetDefult()'
collect2: error: ld returned 1 exit status
How to include the .h
file and make the program run successfully?