dimanche 5 novembre 2017

Why is this code in g ++ / clang wrong, there is no error in VS2013? [duplicate]

This question already has an answer here:

#include <iostream>

class Name {
public:
    Name(int i) : a(i) {}
    int a;
};
void func(Name& a) {
    a.a = 2;
    std::cout << a.a << std::endl;
}

int main(int argc, char* argv[]) {
    func(Name(1));//error
    return 0;
}

Why is this code in g ++ / clang wrong, there is no error in VS2013?

Aucun commentaire:

Enregistrer un commentaire