For the following code template_eg.cc:
Why when I complie I get the following errors:Code:template<typename T> class MyArray { public: MyArray(); MyArray(MyArray& copy); MyArray& operator=(MyArray& copy); }; class MyData { public: MyData(MyArray<int>& x, MyArray<int>& y); const MyArray<int>& x(); const MyArray<int>& y(); }; MyArray<int> read_data(int*, char**); void make_changes(MyData* edit); int main(int argc, char* argv[]) { const MyArray<int> read_x = read_data(&argc, argv); const MyArray<int> read_y = read_data(&argc, argv); MyData user_data(read_x, read_y); MyData edit_buffer(user_data); make_changes(&edit_buffer); }
I new to using templates. Thx.Code:coletek@spamisgood:~/sandbox/cc> g++ template_eg.cc -o template_eg template_eg.cc: In function ‘int main(int, char**)’: template_eg.cc:23: error: no matching function for call to ‘MyArray<int>::MyArray(MyArray<int>)’ template_eg.cc:6: note: candidates are: MyArray<T>::MyArray(MyArray<T>&) [with T = int] template_eg.cc:24: error: no matching function for call to ‘MyArray<int>::MyArray(MyArray<int>)’ template_eg.cc:6: note: candidates are: MyArray<T>::MyArray(MyArray<T>&) [with T = int] template_eg.cc:26: error: no matching function for call to ‘MyData::MyData(const MyArray<int>&, const MyArray<int>&)’ template_eg.cc:13: note: candidates are: MyData::MyData(MyArray<int>&, MyArray<int>&) template_eg.cc:11: note: MyData::MyData(const MyData&)



LinkBack URL
About LinkBacks




CornedBee