Write your question here.
As soon as my project has two header files I always get an error in file Makefile.win
on line 25. The error is:
C:\Martin\MalikChapter1\TestBook.o TestBook.cpp:(.text+0x0): multiple definition of `main'
C:\Martin\MalikChapter1\main.o main.cpp:(.text+0x0): first defined here
C:\Martin\MalikChapter1\collect2.exe [Error] ld returned 1 exit status
25 C:\Martin\MalikChapter1\Makefile.win recipe for target 'myAuthor.exe' failed
Okay Peter87, I went to my original project called Author and I deleted the three files that belong to the book program that inherits from author. I then created a new project and I put in the three files, book.h, book.cpp and the main program there called TestBook and I still got the same error. Now what should I do if I have two classes , i.e the main class and a second class that inherits from the main one because both of them have their main programs?
If I run the first class called Author on its own with its three files , Author.h , Author.cpp and its main it runs 100% okay.
Also when I run the second class Book which also have its three files , Book.h , Book.cpp and its main called TestBook inherits from Author and I put all the the six files in one big file, the Book class also run 100% okay.
But that is not a professional was of working with projects and classes that inherit from other classes.
Your terminology is all messed up and makes me wonder if you know what you're doing or if you're cargo-cult programming. Files don't inherit from each other. Classes don't run. There is no such thing as "the main class".
When I removed one of the main driver testing programs from the project each one ran 100% okay. So you are 100% correct Peter87, and thanks for that. I learned that the hard way. I really never new what was the problem.