我的以下课程有未定义的行为?我认为它定义明确,因为我通过引用传递构造函数参数。我对吗?
class C
{
int* elem;
public:
C(int s[]) :elem(s){}; // Array arguments passed by reference, so its well defined?
void Print()
{
cout << elem[1] << endl;
}
~C()
{
delete[] elem;
}
};
int main()
{
C x(new int[2]{1,3});
return 0;
}