Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

144 Neutral

About fallenang3l

  • Rank
  1. Quote:Original post by Anonymous Poster Quote:Original post by fallenang3l It's because operator new and the new operator are two different things. Operator new just allocates memory, while new operator initializes it. Huh? Didn't you get the memo? j/k Example: foo* f = new foo; new is a language keyword (duh) that's an operator. It's precise name is new operator. It cannot be overridden. However, it calls a function called operator new (words swapped) that you can override to allocate memory however you want, but that it's. Operator new allocates, new operator calls the constructor and therefore it initializes.
  2. That the worst way to see if your application leaks memory. Either use crt memory debug functions or something like fluid studios memory manager.
  3. It's because operator new and the new operator are two different things. Operator new just allocates memory, while new operator initializes it.
  4. I don't think you're supposed to use a raw pointer as a key in a map because of some sorting issues (maybe somebody can explain why cause I'm not sure); however it is safe to use std::string instead.
  5. fallenang3l

    Alright Ive decided to jump into C++

    Mastering C++ itself as a language will take you 2 years or so. Learning the theory behind computing (data structures, algorithms, , etc), graphics, networking and and applying those to really understand is a few years work. Maybe in 5-10 years, if you get a team, you'll be able to start on your MMORPG. Good luck.
  6. Quote:Original post by _the_phantom_ no, you'll get a pointer to a const character array, they just happen to be used as strings, thats all [smile] No, string literal is not an l-value so a temporary std::string object will be created and bound to the reference.
  7. fallenang3l

    Exception Handling

    SiCrane has a good point. Exception handling is not about having try/catch littered everywhere (in fact, you should aim for having very little of those), but about having automatic objects that adhere to RAII.
  8. fallenang3l

    Rotation Equations've Got Me Stumped

    This article should clear up your doubts.
  9. fallenang3l

    Exceptions and performance

    Quote:Original post by Kibble In the Unreal engine when there is an error, you get a stack trace. I believe this is implemented by having a try-catch in every function that shows up in the stack trace in the error message at the end, and Unreal isn't slow. I also do it this way and it doesn't seem to slow it down. No, it just has an automatic object that adds the function name to some static stack somewhere. Your way is just backwards.
  10. fallenang3l

    Exceptions and performance

    Quote:Original post by snk_kid The problem is you can't always release resources if its not seen in the scope of the catch statement, this is where you need to employ RAII techniques. Exception Handling in C++ is a little flawed, it was introduced late into the language and wasn't taken very far (as Bjarne's describes in the design of c++), languages such as java do exception handling better. I actually think that Java's exception handling is worse. Finally clause is brittle and so are required exception specifications.
  11. You can't derive if the base class has a private destructor. You can make it protected, but then if you derive, the user can create the derived class on the stack (and therefore the base part will be on the stack also). There is no good way to require a class to be on the stack/heap. The best you can do is put a comment in the code.
  12. fallenang3l

    Friend vs. Static

    Quote:Original post by Polymorphic OOP A friend function is not required to have a parameter of class type according to the standard. For instance, the function can take no parameters and is still perfectly valid as a friend. Even in a case where you may need multiple versions of the function (different depending on class type it is associate with), you can determine which one by making the function templated and just explicitly calling a specific instantiation. No class instance is required. This is what I'm talking about: class foo { friend void bar() { // ... } }; int main() { bar(); // compile time error, bar function was not injected into the global namespace on a standard compliant compiler (MSVC is not standards compliant in this case), so the compiler doesn't know where to look for it. } You're right that you can write a friend function like that, but you can't call it, so what's the point?
  13. fallenang3l

    Friend vs. Static

    A friend function must have a parameter of class type otherwise a standards compliant compiler will not be able to look it up (name is not injected into outside scope - be it global or namespace). A static function has no such restriction. In other words, you have to invoke a friend function with an instance of the class, but you can call a static member just by fully qualifying it with class name.
  14. You're thinking of this: int obj; int& ref = obj; int&& rref = ref; // illegal
  15. fallenang3l

    Multiple cpp files

    If you change just a single thing in a gigantic cpp file, the whole world is getting recompiled and you might as well go take a nap. If you split your project into multiple translation units (and you have to be smart about it too, like using the pimpl idiom), you can mitigate the long recompilation problem.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!