+ 1
How can i write c++ program in different files
what do i need to include header files & .cpp files .I really don't understand how to write a program in different files in c++ i mean what to write in them.plz explain in brief
6 Answers
+ 4
every class should have an own CPP and header file
+ 3
it is common practice to define classes in headers and then do the implementation in a cpp file. Means Zou write something like into func(int); in the header file and then you have to write the implementation in the CPP file int X::func(int b){ return b; } that's just an example
+ 3
but if i want can i write classes in different files without header files?
+ 3
but you can write of course everything directly in a cpp file, it's just not very good practice
+ 3
and don't forget about the main file to test it all (you have to include all the headers)