#include <iostream>
#include "_Array.h"
usingnamespace std;
int main()
{
int n[4] = {4,3,2,1};
_Array Obj;
Obj >> n;
}
ERROR:
J:\C++\ArrayFunctions\_Array.cpp|10|error: '_Array operator>>(const int*)' must have an argument of class or enumerated type|
||=== Build finished: 1 errors, 0 warnings ===|
Usually sizeof( int * ) is equal to 4 ( on 32-bit platforms) that means that the result of the expression will be 1 (sizeof( int ) is also usually equal to 4).
If you are trying to "shift" the array into an object of your class then it will be more naturally to use the operator << instead of >>
Also you need know the size of the array.
Taking all this into acccount your operator will look the following way ( have removed the underscore in the class name)
1 2 3 4 5 6
template <size_t N>
Array & operator <<( int ( &ar )[N] )
{
for ( auto x : ar ) Data.push_back( x );
return ( *this );
}
both of these options just give me a ton of errors and confuse the living hell out of me..... i guess ill just head back in my book and try to re-learn again..