samedi 23 avril 2016

How is the value being assigned to the member of the class in the code below?

In the code snippet how is 10 getting assigned to x ? There is no definition for copy constructor, so the default one is being used.

class X 
{
public:
    int x;
};

int main()
{
    X a = {10};
    X b = a;
    cout << a.x << " " << b.x;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire