1. When passing objects between each other is it preffered to use references if not what then?
5. When allocating resources should you always do it inside of a class?
To answer your first question: yes, the preferred way of passing objects ispass by reference
In your fifth question you make an assumption which is wrong (unless you implement a destructor for your class as well), if you use dynamic memory allocation inside a class, and you don't make use of a destructor, the memory won't be freed :)
And regarding question 4, what SDK are you talking about? It's common in class libraries that there are rules to name for example variables or functions, i.e. to make it easier for the programmer to go through/read the code :)
Could you be more specific in your second question?
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Yes I was assuming a destructor was implemented but my question still applies should I allocate all my resources in classes?
If you mean all resources (also variables which aren't on the heap) , then I would answer no, in a class you put elements and functions related to each other.
However, it seems like you're pulling in the direction of a garbage collector.
If you like this concept, then it would be probably better to Google on "C++ Garbage Collector" or something :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
<strong>bob = *Astring;</strong> won't copyAstring in bob, for that purpose you'll have to use the following code instead: strcpy(bob, Astring); :P
>However there is no real *right* way of doing it
But there are good and bad ways to do it :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
>I didn't think non heap variables could be said to be allocated because they are allocated by the OS at startuptime
Not necessarily, they're automatically allocated when the code block in which they're defined is entered/executed :)
BTW, what would be the advantage of wrapping all the variables of your program in one class? (what advantages do you see in it?) I don't see any advantage in it, I find it sluggish and a very bad coding practice as well ...
Remember: It's not because you can do something that you'll have to do it as well :P
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243