cassius Posted June 9, 2013 Share Posted June 9, 2013 I am brushing up on my c++ knowledge after not using it for some time. I know that function headers are put in files with the "h" extensions but is it ok to put the actual function in the same file? Or is it considered bad form?? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Rick Posted June 10, 2013 Share Posted June 10, 2013 You want the prototype in your header and the actual insides in .source files (cpp). Quote Link to comment Share on other sites More sharing options...
cassius Posted June 10, 2013 Author Share Posted June 10, 2013 Yeah, I had forgotten that. It works ok but I won;t do it in my current le3 project. In my le2 game the code was getting a bit bulky so I decided to put all my functions in a seperate file. I called it func.h. I guess it should have been called finc.cpp Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
tjheldna Posted June 10, 2013 Share Posted June 10, 2013 I think it's fine to put your getters and setters in your headers, but anything above that I'd put everything else in the .ccp IMO. I've ran into some linker errors when playing around with objects in the header and were real hard to track down. Quote Link to comment Share on other sites More sharing options...
cassius Posted June 10, 2013 Author Share Posted June 10, 2013 At the time I had forgotten about prtotyping and forward references. All the variables were declaed inside main. but it worked. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.