vendredi 30 décembre 2016

What is the difference between these two approaches?

class A
{
   int a = 100;
};

and

class A
{
    int a;
public :
   A()
   {
      a = 100;
   }
};

I know that there are two approaches because static variables are initialised outside the class and cant that cant be done inside the class. But what difference does it make if i initialise the variable a ( a normal int ) using the constructor or during the declaration itself.

Aucun commentaire:

Enregistrer un commentaire