Jump to content

  • Log In with Google      Sign In   
  • Create Account

Radikalizm

Member Since 05 May 2011
Offline Last Active Today, 07:19 AM
*****

Posts I've Made

In Topic: PSP games in C++

05 March 2013 - 10:50 AM

"but you can use any language that compiles to the target architecture"
Do the devices only accept their assembly language?
 
If not, how high level can you go for the popular devices?

 

You have to remember that an assembly language is not the absolute lowest level you can reach, even assembly needs to be assembled into the platform's machine language in order to create an executable.

 

And you can go as high level as you want for any platform, as long as there's a compiler available which compiles down your high level code into those machine instructions.


In Topic: Want to learn programming...again

27 February 2013 - 07:25 AM

Thanks for the prompt responses. What's the main differences between C# and C++? 

learning c++ is better, i learned c++ and vb and I can recognize c# codes and even code or script with them without learning

 

Learning C++ isn't at all "better" than learning C#.

 

C# is a very powerful language with a huge amount of libraries available as NightCreature mentioned, and it is considered to be much more beginner friendly than C++ is.

Modern C++ (ie. C++11) is a vast improvement to 'old' C++ when it comes to usability, but it's still completely possible to do things horribly wrong in very spectacular ways without being given a clear reason why things went wrong. This is not a position you want to be in when getting (re-)acquainted with programming.

 

Focus on the essentials of the actual programming first, not on all of the additional things C++ makes you go through. C# is a very good language for this, and it has a bunch of game-related libraries you can jump into from day 1, although it definitely isn't the only choice available.


In Topic: Your top "mind = blown" moments

14 February 2013 - 11:12 AM

It... It exists! http://www.cyberpuck.com/

My god... the fabled hockey mmo with HTML and variables!


In Topic: Searching nice guys for a Game Project

11 February 2013 - 08:29 AM

Please use the classifieds for recruiting :)


In Topic: Rule of Three, and const-correctness questions

05 February 2013 - 04:04 PM

The reason for the C++ rule of three is that it's highly possible that if you had to implement your own copy-constructor, destructor or copy assignment operator because you needed different behaviour from the compiler-generated versions, the other 2 functions won't suit your needs either. 

 

An example

class Foo
{

public:
  
  Foo()
  {
    m_bar = new Bar();
  }

  ~Foo()
  {
    delete m_bar;
  }

private:

  Bar* m_bar;
  
};

 

In this example the default compiler-generated copy constructor or copy assignment operator would just copy the given pointer over to the destination instance. This would cause undefined behaviour once the destructor of a copy instance of Foo would get called.

 

 

The issue of const-correctness goes much deeper than just function arguments, it also applies to class methods (does a certain method change class data, or not?), return values, etc.

The easiest way to think of it is that if your data should remain immutable you should declare it as const. If a method operating on class data does not change this data, it should be declared const as well.

 

class Foo
{
public:

  // We declare this method as const, since it doesn't modify any data
  int getSomething() const { return m_something; }  

  // This method modifies our variable, so it shouldn't be declared as const
  void modifySomething(int n) { m_something += n; }

private:

  int m_something;   
};

 

 

To address your example about your Update function, passing a const argument by value is not what you're looking for. When you pass an argument by value, its contents will get pushed on the stack, so if you pass a variable as an argument to this function, the original variable will not get modified.

 

This does become an issue however when working with references. Try to find out for yourself what could happen to the arguments of type Bar in the following methods:

 

class Foo
{
public:

  void doSomething(const Bar& b);
  void doSomething(Bar& b);
};

PARTNERS