I am new to vs code, after previously using atom a little bit. I am working on c++ with a program that has some classes in separated files. I have already installed the c/c++ extension, but I am facing a problem. When I try to run the program with all it's files included, it shows me the following error:
main.cpp:(.text+0x1f): undefined reference to `Car::sayHello()' collect2: error: ld returned 1 exit status. the code is pretty basic.
#include <iostream>
#include "Car.h"
using namespace std;
int main(){
Car c;
c.sayHello();
cout << "Hello world";
return 0;
}
From what I remember from atom, selecting all the files and running them would solve the problem, which I think is the same as running the following command in the terminal:
g++ Car.cpp Car.h main.cpp -o Classes
I have tried these in vs code and the problem seems to appear again. Help is much appreciated.