Reputation: 313
Please just answer my simple question I am making separate file for classes .h file and separate for functions and one main.cpp file
Should I also put functions which are not part of the my class in separate cpp file?? Actually some of my functions of class are also using other function not included in the class function. So should I put all the functions including and not including in separate cpp file?
Upvotes: 1
Views: 147
Reputation: 50046
Should I also put functions which are not part of the my class in separate cpp file??
if those functions are not strictly used only by your class then yes, ie. if they can be used in different projects, then it makes sense to put them in separate .cpp file.
Actually some of my functions of class are also using other function not included in the class function. So should I put all the functions including and not including in separate cpp file?????
hard to understand, but as above if those functions are only for your class use, then put them in .cpp file that contains implementation for your class methods.
Actually if you put some declarations in header file a.h
then you also put their definitions into a.cpp
. This is not a strict rule, you can put declarations in 'a.h' and 'b.h' while put all the definitions in c.cpp
, but then its hard to find where which function is declared. If you know that declaration is in a.h
then you simply look for definition in a.cpp
.
Upvotes: 1