class - c++ compile error -
i have class double linked lists:
template <typename t> class akeraios { struct node { t data; node* prev; node* next; node(t t, node* p, node* n) : data(t), prev(p), next(n) {} }; node* head; node* tail; public: akeraios() : head( null ), tail ( null ) {} template<int n> akeraios( t (&arr) [n]) : head( null ), tail ( null ) //meta apo : simainei einai initializer list--arxikopoiisi listas { for( int i(0); != n; ++i) push_back(arr[i]); } bool empty() const { return ( !head || !tail ); } operator bool() const { return !empty(); } void push_back(t); void push_front(t); t pop_back(); t pop_front(); ~akeraios() { while(head) { node* temp(head); head=head->next; delete temp; } } }; and somewhere in main
int arr[num1len]; int i=1; akeraios <int> dlist ( arr );//error line!! for(i=1;i<=num1len;i++){ double digit; int div=10; int j; for(j=1;j<=i;j++)div=div*div; digit=number1/div; int dig=(int) digit; the error in error line is:
no matching function call `akeraios::akeraios(int[((unsigned int)((int)num1len))])'
candidates are: akeraios::akeraios(const akeraios&)
note akeraios::akeraios() [with t = int]
this code valid , compliant as-is. way can see messing if had compiler extension vlas , attempted call constructor variable-length array, fail. otherwise, legitimate. visual studio accepts without quarrel.
Comments
Post a Comment