Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Windows / T2, C++, VS2015 and .h V's .cpp (and farewell Tier1)

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 21st Feb 2021 19:44
I am not known as being a lover of C++ or VS, I dumped MS dev environments after they dropped VB6 way back when, when I got over the shock I used RealBasic among other platforms for a while all were lacking something then I found the holy grail of Basics and it was Pure, Then the world went mobile crazy and PB seemed a bit outdated (In looks but not functionality, its still the best out there IMO), I tried various platforms and finally found AppGameKit, all the while along this journey I avoided VS/AS and C++ ..... I'm an Idiot!!!

I had to install VS to compile something unrelated to agk and while it was active I thought I'd take a poke round the CPP templates, then just started coding (as you do!), porting my basic libs and like wow I am already seeing a pretty decent speed improvement, I should have done this a long time ago, so sorry to say farewell to tier 1 its been a good companion but its deffo time to step up, I do know enough CPP to at least port my libs so a good start point (that C++ for dummies book I read a few years ago finally got some recall value!, lol)

So needless to say while in OOP land I am using classes for my libs, and this is where my understanding of "typical" C++ norms maybe outdated, so typically the class gets defined in the .h and declared in the .cpp which has made sense for how long??.... exactly

So now I am seeing some pretty mainstream C++ library's out there that are "header only" as in, the function declarations are either inside the class definitions or declared in-line below the class, a bit of a google on the subject reveals a very split opinion on the matter with most conserving tradition, but a small portion of people seem to see some kind of logic in this approach, myself included, I like the idea of a self contained header file, and to the point of this thread, what do YOU guys think, good file management or bad coding practice?

Also, taking an integer approach to things in basic can be forgiving, you get notchy movement and stuff but for the most part it works, pass integers around in tier2 and the compiler has quite a lot to say about it, so, define as floats or cast integer variable as floats, or not bother, there only warnings?

I don't think my OCD would let me leave them but yet other 3rd party libs write an essay of warnings every time I compile, is it the norm to ignore compiler warnings?
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 27th Feb 2021 04:41
Having separate headers and CPP files for each header does allow them to be compiled into libraries when required for distribution.

It's seen as a good coding practice to have declarations in the header file and code in respective CPP files but it's down to personal preference. Back in the 90s I used to use self contained files but as my knowledge grew I moved to separate files for ease of distribution as libraries.
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp

Login to post a reply

Server time is: 2024-11-17 22:38:03
Your offset time is: 2024-11-17 22:38:03