Search code examples
c++eclipseeclipse-neon

eclipse - making a c++ project that allows you to create multiple main classes


So I am trying to figure out how to use c++. The first step is to get a GUI that will work well, so I decided to use eclipse as I have used it frequently with java. However, while it is easy enough to make several files in java that all have the same main class within a folder, I can't figure out how to do it with c++. Note: (I want several main classes because I'm not making a huge program, rather, I plan to create several small programs for competitive programming sites like codeforces.) I've tried to figure out makefiles and .h and .cpp but none of it works for me (likely because I don't really know how to use them).

I don't know what kind of project to create (that is, executable, shared library, static, makefile project) that will best suit my purposes. I've tried lot with what seems to be the default (executable) and what I've heard some people say I should use (makefile) but haven't gotten anything satisfying.

Picture of this menu

When I try to use executable I always get an error saying I can't have multiple main() functions as soon as I add another class, even if I make the main function private in the .h file.

Picture of this error

When I try to use the makefile like I've seen people suggest, well, I don't even know what a makefile is and honestly it doesn't seem to do much, when I delete it nothing changes and I can't even run the other classes, when I try to it just runs the one with the same name as the project, run configurations don't really change anything.

Please help, I've been stuck on this for hours :(


Solution

  • I would suggest finding some good tutorials online and following them to learn a bit more about the language and its ecosystem in general, first. IDEs are great as they make things easier for professionals, but can be overwhelming for someone just starting out.

    It's better to learn the raw tools that you would need to build an application, so you can appreciate what the IDE does for you, and why.