Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to manage multiple subproject in 1 C++ project?
    primarykey
    data
    text
    <p>I'm using Eclipse CDT. The idea is that I want to manage, for example, 10 small excercises (10 unrelated problems) in 1 project as it seems not optimized to create 10 projects. I am using a model like this: There is a cpp file contain main() called "Controller.cpp" followed by its header "Controller.h".Each problem 1 class, for ex : "ex1.cpp" &amp; "ex1.h" -> 22 files in total. In main(), I use a switch to choose what problem to solve. However, don't know why but each class, I have to type prototype for function in "<em>.cpp" and prototype in "</em>.h" (both inside and outside class) for it to work :</p> <p>"Controller.cpp":</p> <pre><code>#include "Controller.h" #include "E2P4.h" #include "E3P3.h" #include "E3P4.h" #include "E3P6.h" #include "E4P1.h" #include "E4P2.h" #include "E4P3.h" #include "E4P4.h" #include "E7P6.h" #include "E7P6Apps.h" #include "E7P7.h" #include "E7P7Apps.h" #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main(){ string choice; cout &lt;&lt; "Enter choice :" &lt;&lt; endl; cin &gt;&gt; choice ; if ( choice.compare("E2P4") == 0 ){ E2P4 A; A.Do(); } else if ( choice.compare("E3P3") == 0 ){ E3P3 A; A.Do(); } else if ( choice.compare("E3P4") == 0 ){ E3P4 A; A.Do(); } else if ( choice.compare("E3P6") == 0 ){ E3P6 A; A.Do(); } else if ( choice.compare("E4P1") == 0){ E4P1 A; A.Do(); } else if ( choice.compare("E4P2") == 0){ E4P2 A; A.Do(); } else if ( choice.compare("E4P3") == 0){ E4P3 A; A.Do(); } else if ( choice.compare("E4P4") == 0){ E4P4 A; A.Do(); } else if ( choice.compare("E7P6") == 0){ E7P6apps(); } else if ( choice.compare("E7P7") == 0){ E7P6apps(); } else cout &lt;&lt; "Wrong command !!!" ; return 0; } Controller::Controller() { // TODO Auto-generated constructor stub } Controller::~Controller() { // TODO Auto-generated destructor stub } </code></pre> <p>Exercise :</p> <pre><code>#ifndef _H_ #define _H_ void Do(); class E2P4 { public: void Do(); E2P4(); virtual ~E2P4(); }; #endif /* _H_ */ </code></pre> <p>and :</p> <pre><code>#include "E2P4.h" #include &lt;iostream&gt; void Do(); void E2P4::Do(){ std::cout &lt;&lt; "Please input Celsius degree :" &lt;&lt; std::endl; double d; std::cin &gt;&gt; d ; double converted = 1.8 * d + 32 ; std::cout &lt;&lt; d &lt;&lt; " C degree corresponds " &lt;&lt; converted &lt;&lt; " F degree"; } E2P4::E2P4() { // TODO Auto-generated constructor stub } E2P4::~E2P4() { // TODO Auto-generated destructor stub } </code></pre> <p>and this is very boring as each function I have to copy prototype 3 times.</p> <p>While recently I found another approach, not treating each problem a class. I use "ex1.cpp","ex1.h", and "ex1Application.cpp" and "ex1Application.h" to indirectly interact with main() .So in "Controller.cpp", in main() I only call that mediator "ex1Application.cpp". And also only have to prototype once. But it needs 41 files at all.</p> <p>Is there any better idea to manage these ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload