normally i use VS19 for C++ programming, but i wanted to try if it works on VSCode on my Macbook, so i wrote i real simple programm
main
#include <iostream>
#include "test.hpp"
using namespace std;
int main()
{
testfile obj(5);
cout << "main.cpp"<< endl;
obj.output();
return 0;
}
class header (.hpp)
#pragma once
using namespace std;
class testfile
{
private:
int i;
public:
testfile(int in) : i(in) {}
void output();
};
class file (.cpp)
#include "test.hpp"
#include <iostream>
using namespace std;
void testfile::output()
{
cout << i << endl;
}
i know i could write the little output in the header, but i want to try if it works if the code is split up into many different files. I get the following error:
(PATH)..\Temp\ccITg6NM.o:main.cpp:(.text+0x48): undefined reference to `testfile::output()' collect2.exe: error: ld returned 1 exit status
the same goes for my windows laptop. I ran the exact same code on Visual Studio and it worked perfectly fine. I tried googling the error but tbh, i didn't got anything out of it...
i run VSCode with C/C++ intellisense and the compile & run plugin.