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

Author Topic: sf::Sprite Rotation causes Crash  (Read 5905 times)

0 Members and 1 Guest are viewing this topic.

Silvah

  • Guest
sf::Sprite Rotation causes Crash
« Reply #15 on: May 07, 2011, 03:40:45 pm »
Well, when one doesn't need to use pointers, one doesn't use new at all, does she?

The question is not "why pointers should be avoided whenever and wherever possible". I assure you that I know why and I completely agree with you in this regard. The question is: what's so bad with new (assuming one has a good reason to dynamically allocate memory)? I always thought there's nothing wrong with new itself, it's the manual deletion what should be avoided.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
sf::Sprite Rotation causes Crash
« Reply #16 on: May 07, 2011, 04:04:18 pm »
Quote from: "Silvah"
What's wrong with, for example, the following code?
Code: [Select]
scoped_ptr<Base> ptr(someCondition ? new DerivedA(foo) : new DerivedB(bar));
The second and third operand of the conditional operator have different types, which is not allowed. :D

I said that manual memory management should be avoided, I explicitly listed new and delete in parentheses. I haven't spoken about new on its own, so you probably misunderstood me.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Silvah

  • Guest
sf::Sprite Rotation causes Crash
« Reply #17 on: May 07, 2011, 04:40:47 pm »
Quote from: "Nexus"
The second and third operand of the conditional operator have different types, which is not allowed. :D
Oh well :D This stuff happens, let's pretend that it was only a pseudocode, or that DerivedA is a base of DerivedB, or something ;)

Quote from: "Nexus"
I said that manual memory management should be avoided, I explicitly listed new and delete in parentheses.
I've read that "and" as "both new and delete should be avoided", but you rather meant "new together with (manual) delete should be avoided". My bad ;)