I wrote this multiple file in c++ (just getting an integer as input and giving back the same number) and I placed all of them in the same directory. When I try to build the main.cpp with CodeBlocks I get the following error: In function 'main', undefined reference to 'grade::show(int)'. Does anyone know what could be the mistake in the code???
PS. It is exactly the same code that I find on my college book.
main.cpp
#include <iostream>
#include "grade.h"
using namespace std;
int main() {
int n1;
grade number;
cin >> n1;
cout << number.show(n1) << endl;
}
grade.h
#include <iostream>
class grade {
public:
int show(int);
};
grade.cpp
#include <iostream>
#include "grade.h"
using namespace std;
int grade::show(int n2) {
return n2;
}