#include<iostream> using namespace std; class Test { public: Test(){} Test(int param):i(param){} int i; }; int main() { Test obj1(100); //Test obj2[100](obj1) ; - This doesn't work I know Test obj3[10] = obj1; //This works cout<<obj3[9].i<<endl; return 1; }
In the above code, Test obj2[100](obj1); does not work, but Test obj3[10] = obj1;
Why the former is supported, but the latter. (Both will call the copy constructor.)
Is it that the former is not supported due to implementation restrictions in compilers?
Edit: I am not using C ++ 11. gcc version 4.8.2 (i686-posix-dwarf-rev3, built by the MinGW-W64 project) Qt 5.3.1
Any conclusion?
source share