Using .h and .cpp files in an online C++ compiler (and why most of them fail)

Most online C++ compilers give you one editor, and one editor means one file. That's fine until your course splits a class into Student.h and Student.cpp. Then the second line of main.cpp stops the build: code.cc:2:10: fatal error: Student.h: No such file or directory 2 | #include "Student.h" | ^~~~~~~~~~~ compilation terminated. Here's why that happens, three ways around it, and the linker errors you'll meet on the way. Why the include fails #include "Student.h" tells the compiler to read Student.h from the folder of the file that includes it. A one-file online compiler saves your code on its
Headline and summary provided via NewsData.io. The full article and its copyright belong to the original publisher.

