source file and header file are not compiled together

Hi everyone, my socket.cpp program got error. it showed "socket.h: no such file or directory". I had put my header file (socket.h) in the same place with my source file. How can i solve this problem? If anyone know, please kindly share me. Thanks millions.
You need to have 3 files: First, you have the socket.h file which contains the headers from main.cpp. socket.h should include any other libraries that your main function might need and any that your socket.cpp file will need

socket.cpp should include the header file as well as any functions that your main function will be using

The last file is your main and should just include your header file and the main function ofc

When you compile, make sure you have all the files in the same folder

If compiling with prompt: g++ -o executable main.cpp socket.cpp
Topic archived. No new replies allowed.