Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Nov 2012
Offline Last Active Mar 19 2014 04:45 PM

Posts I've Made

In Topic: Error accessing vector member

05 November 2012 - 03:21 PM

Thanks for taking time to give suggestions, you guys are awesome.

That forward "thing" looks interesting. I need to invest more time in the new features.

~10 years in manage code and coming back feels a totally new language Posted Image

Thanks again Posted Image

In Topic: Error accessing vector member

05 November 2012 - 02:34 AM

Of course now you have to ask yourself who is responsible for cleaning it up and when should that happen. Rule of thumb: for every "new" that isn't assigned to a smart pointer, there must be one (and only one) "delete".

I'm deleting in the destructor of controls class. Don't know if its enough. Something like this:
	for(cControl *ctrl : this->listControls)
	 delete ctrl;

So, either you need to A) manually micro-manage your memory, or B) Let C++ manage your memory for you using smart pointers.

Yeah I know. I still have in my checkup list the use of smart pointers, since I've seen that's whats being used to ease memory management.

Why's every one of your classes start with the lowercase letter 'c', and what does it stand for? If 'c' stands for 'class', that's a little bit redundant don't you think? Posted Image
(See: [CStupidClassName] Sometimes programmers see someone else do something, don't know why it's there, adopt the practice, and then spread that practice to other programmers)

LOL, I've been using that for a while, didn't knew it was a thing.
I usually use the c as a prefix for instanced classes and without the c for static (singleton).

Thanks for the comments guys,

In Topic: Error accessing vector member

04 November 2012 - 12:30 PM

Your cLabel objects are created on the stack and you are storing pointers to them in the vectors. This is bad juju as they get destroyed when the function that contains them exits. Two possible fixes are either heap allocate them with new or store by value rather than by pointer.

Awesome SiCrane, thank you so much.

I've changed to:
cLabel *CreateLabel()
  cLabel *pLabel=new cLabel();
  // #1

Seems to be working fine now