Author Topic: How do I add files to another project without having to make a class?  (Read 1153 times)

Offline icewizard

  • Single posting newcomer
  • *
  • Posts: 7
I'm new to c++ and whenever I want to make a header file it only works if I make a class. When I try to add files to another main.cpp manually I get a page with a lot of code that I didn't write and an error occurs, or the file gets added but its in a seperate folder and says something like "undefined reference to main".

when I try adding files to another project manually, the kml project to ioj, I have  a bunch of code that I didn't write and its causing errors when I compile. The code I wrote is in the main.cpp file, but when only that is there then I get the error saying "undefined reference to main". And it shows two folder pictures under the source folder, but when I make a class there is only one folder under the source file folder and it shows main.cpp and other cpp's and it works fine like in my picture.

Whenever I make a forward declaration or a header file I have to make console project and then a class or I'll get errors, shown in my picture. How can I add files to another project correctly to make it work so I don't have to make classes all the time? in the picture, making a project and then a class is the only way I know how to link files to  a project and get it to actually work. Do I have to change the name of main.cpp to get it to work? and I want to try adding multiple files to the same project without errors, because I can't do this with a class without getting the same errors I mentioned earlier.