Project in Codeblocks IDE

SO IN uni we started software engineering in java and is so nice how different classes are organized under one project and packages and come run time the compiler is able to find everything .
the sweet thing about this is that I can write as many short codes as i want, i just have to implement the right interface and tag the right package and all is well...

but how do i do the same for c++ in codeblocks ide for example?
how should i name the files? should i name my main source file main? and if in main calls a functions which finds itself in another source code..how does the compiler knows where to look?
is there a way to go about it like it is done in java?
THANKS IN ADVANce for your responses
a

actually i prefere programming in c++ to java..but the organisation in java is just sooo superb...the interface thing is just genius :D

Last edited on
I always name my main, basically main.cpp. If you then create a class, the cpp and h file is created inside the project, where your main.cpp file is, thats where the compiler looks as far as I know. In your main.cpp, you must include the class. Say you created a class called Animal. At the very top of your main.cpp you type

#include "Animal.hpp"
Last edited on
oh ok :) thanks Tarik...
but lets say i didn't create other classes in the other source codes..lets say some functions and stuff...so to make main see them i just have to be including ???

#include name_of source_file1;
#include name_of_source_file2;

and i should be good?
So, there is this guy named bucky on youtube, with excellent guides on c++. After you watch them, you'll be an expert on the basics (more or less). And he happens to use Codeblocks :)

Check out the videos you wont regret it - https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83

Your question will be answered video 12-13 in his tutorial.

If you want functions in other cpp files, then you create a class and in the h file declare the functions, and then in the cpp file define them. Then in main, first you do the include thing that I told you, and then you create an instance of the class. And through that instance you will be able to access functions and variables. As I said, all explained in his tutorials.

Happy coding!

P.s. Code with him, dont just watch.
THANKS THANKS THANKS
Topic archived. No new replies allowed.