I have a cpp file that does one thing. and then have my main cpp file that i want to call the the other.
ie. say main.cpp calls calc.cpp. If that possible? how would you do it because i though you would #inlclude "calc.cpp" in main.cpp but it keeps saying
[Error] redefinition of 'int main()'.
If its not good pratice than I guess i could make a function in main to do it. but curious if it can be done.
calling a cpp file from another cpp file error
Page 1 of 11 Replies - 191 Views - Last Post: 11 September 2012 - 08:35 PM
Replies To: calling a cpp file from another cpp file error
#2
Re: calling a cpp file from another cpp file error
Posted 11 September 2012 - 08:35 PM
The main function is where the program starts, so it cannot start in two places.
You could rename the main in one file and call it in another.
Although you can #include "calc.cpp" in main.cpp and it may work (up to a point), it is usual to add the other cpp file to your project.
Header file
You could rename the main in one file and call it in another.
Although you can #include "calc.cpp" in main.cpp and it may work (up to a point), it is usual to add the other cpp file to your project.
Header file
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|