#include <iostream>
using namespace std;
typedef struct A {
int one;
int two;
A(int a, int b) : one(a), two(b) {}
A(pair<int, int> v) { A(v.first, v.second); }
}A;
pair<int, int> f() {
return pair<int, int>(3, 4);
}
int main() {
A a(f().first, f().second);
cout << a.one << ' ' << a.two << endl;
return 0;
}
요렇게 하면 3 4 가 출력 됩니다. 의도한 결과죠. 하지만
#include <iostream>
using namespace std;
typedef struct A {
int one;
int two;
A(int a, int b) : one(a), two(b) {}
A(pair<int, int> v) { A(v.first, v.second); }
}A;
pair<int, int> f() {
return pair<int, int>(3, 4);
}
int main() {
A a(f());
cout << a.one << ' ' << a.two << endl;
return 0;
}
왜 이렇게 하면 이상한게 출력되나요