Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 Sep 2005
Offline Last Active Mar 01 2014 02:38 PM

Posts I've Made

In Topic: Wondering how heap allocation works with classes[c++]

25 February 2014 - 11:30 AM

You do not need to free Bar since it is in declared in it and when you free Foo it gets removed automatically as Hodgman sad.

If you create Bar in Main() it gets created on stack in this function and its removed automatically as you leave the function since stack on this function no longer exists. Similar is with the heap. But you need to remove it manually and when you do its all contents is removed.

In Topic: Branching in switch statement

24 January 2014 - 03:57 PM

I agree with Nypyren. In some languages like C/C++ switch statements can be really fast. If you look at assembly code and your switch has like 1000 case statements in switch the code goes immediately to the desired case where in if else statements the code has to go trough every one to get to the desired one.

In Topic: Branching in switch statement

23 January 2014 - 03:17 PM

That looks interesting. I did not know abaut corutines.

In FSM for states I used enums and I would switch to a new state trough case statements. But I think functions could be also part of a state so functions could have the same name as a state. So if we need to switch to another state without using while we could just call another state function.

In Topic: Branching in switch statement

23 January 2014 - 02:33 PM

I was building a finite state machine where I don't need a while statement but instead I just needed to switch to another state right after the first one finished.

How would you transform the current code to put it out in a function ?

In Topic: Branching in switch statement

23 January 2014 - 12:44 PM

I didn't know that. It looks like an old basic code smile.png. Is this a good coding practice ?