Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

891398 Posts in 33542 Topics- by 24777 Members - Latest Member: Amy

June 19, 2013, 04:39:18 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Advice on what platform to start game in
Pages: 1 2 [3]
Print
Author Topic: Advice on what platform to start game in  (Read 1721 times)
rivon
Level 10
*****



View Profile
« Reply #30 on: November 17, 2011, 05:42:47 PM »

I don't do this myself but I think the best for a beginner would be to write down all the dynamically allocated variables used, then all classes they are passed to, then make sure that once they are not needed at the places they were passed to, the reference to them is deleted (pointer NULLed etc.) and of course that the variable is deleted at the end when it's not needed. Then just check all your code and tick the parts which are ok. Then of course correct the ones which aren't.

And I'm sure someone here would suggest using smart pointers. So that's another possibility.
Logged
eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile WWW
« Reply #31 on: November 17, 2011, 06:22:12 PM »

And I'm sure someone here would suggest using smart pointers. So that's another possibility.

That's the correct possibility. Why would you want to manage memory when you don't have to?

std::shared_ptr

THAT IS ALL YOU NEED TO KNOW YOUNG APPRENTICE
Logged

I am eclectocrat.
I make Mysterious Castle, a Tactics-Roguelike (TIGSource devlog).
randomnine
Level 1
*


View Profile WWW
« Reply #32 on: November 18, 2011, 02:37:47 AM »

std::shared_ptr

Circular references.
Logged

eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile WWW
« Reply #33 on: November 18, 2011, 04:12:17 AM »


Better than segfault.

PS. std::weak_ptr
Logged

I am eclectocrat.
I make Mysterious Castle, a Tactics-Roguelike (TIGSource devlog).
Klaim
Level 10
*****



View Profile WWW
« Reply #34 on: November 18, 2011, 04:49:40 AM »

also

Code:
boost::scoped_ptr

and if you have access to a C++11 compiler with some features

Code:
std:unique_ptr

I'm using this one a lot, it's so useful!

C++ is longer to learn correctly than other language, it's not that hard but quantity of features makes it complex.

Also, it's pass-by-value by default, not pass-by-reference in function parameters, don't forget that when you're trying to apply your C# idioms in C++........





...ok I'm being a bit sarcastic, I just wanted to say (again) that you should take C++ as a language very different from C# and Java. I agree it's not really true but you'll fall in dangerous traps by not taking it that way.
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #35 on: November 18, 2011, 06:15:01 AM »

It's relatively easy to create an access violation error - much harder to track it back to the source.
And even easier to create a memory leak.
As others said, use some sort of smart pointer.  It will make your life a hell of a lot easier (especially since you are coming from a memory managed background and this stuff hasn't been beaten into you yet).
Logged

iEnjoyFreeBacon
Level 0
***



View Profile Email
« Reply #36 on: November 18, 2011, 07:06:43 AM »

I understand that C++ is a totally different beast from a managed language but I wanna conquer that beast lol and be a C++ pro  Smiley

but before I get there I gotta be a noob so what is
Code:
boost::scoped_ptr
more specifically the '::' operator, is that referencing a namespace?
Logged

You prolly are I doubt?
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #37 on: November 18, 2011, 09:52:30 AM »

You are on the money there re: "::".

Although, it could also be a static member of the class (doesn't really make sense in this case, but it could be).
Logged

Klaim
Level 10
*****



View Profile WWW
« Reply #38 on: November 18, 2011, 10:35:40 AM »

It's what we call "scope resolution operator". When you want to use the name of something in the language, you need to use it's full name or partial name depending on where your code is.
For example boost::scoped_ptr is a class name scoped_ptr in a namespace boost. As already said, you don't know if it's a type, a function, an object, or another namespace (until you try to do something illegal with it and compilation fails).
In C++ there is often no way to know what is what from just one line. Everything depends on the context where the code is written (and that makes why C++ compiler are " a bitch to implement" - not my words).
In fact scoped_ptr is a template class... but I think you'll understand once you know about all that after having read some books I guess. Don't bother for the moment.


Quote
I understand that C++ is a totally different beast from a managed language but I wanna conquer that beast lol and be a C++ pro

As far as you understand that it's different, you're in the good attitude. Now take a book.
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
Pages: 1 2 [3]
Print
Jump to:  

Theme orange-lt created by panic