记录详情

Compile Error

/in/foo.cc:26:14: error: 'T1' has not been declared
     template<T1>
              ^~
/in/foo.cc:27:30: error: 'T1' was not declared in this scope
     friend void Swap(CArrary<T1> &a, CArrary<T1> &b);
                              ^~
/in/foo.cc:27:32: error: template argument 1 is invalid
     friend void Swap(CArrary<T1> &a, CArrary<T1> &b);
                                ^
/in/foo.cc:27:46: error: 'T1' was not declared in this scope
     friend void Swap(CArrary<T1> &a, CArrary<T1> &b);
                                              ^~
/in/foo.cc:27:48: error: template argument 1 is invalid
     friend void Swap(CArrary<T1> &a, CArrary<T1> &b);
                                                ^
/in/foo.cc: In member function 'CArrary<T>& CArrary<T>::operator=(const CArrary<T>&)':
/in/foo.cc:100:25: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
                         if(ptr)
                         ^~
/in/foo.cc:102:29: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
                             ptr=new T[a.size];
                             ^~~
/in/foo.cc: In instantiation of 'void Swap(CArrary<T>&, CArrary<T>&) [with T = int]':
/in/foo.cc:138:13:   required from here
/in/foo.cc:112:23: error: 'int CArrary<int>::size' is private within this context
       T * tmp=new T[b.size];
                     ~~^~~~
/in/foo.cc:13:9: note: declared private here
     int size;
         ^~~~
/in/foo.cc:113:20: error: 'int* CArrary<int>::ptr' is private within this context
       memcpy(tmp,b.ptr,sizeof(T)*b.size);
                  ~~^~~
/in/foo.cc:14:8: note: declared private here
     T* ptr;
        ^~~
/in/foo.cc:113:36: error: 'int CArrary<int>::size' is private within this context
       memcpy(tmp,b.ptr,sizeof(T)*b.size);
                                  ~~^~~~
/in/foo.cc:13:9: note: declared private here
     int size;
         ^~~~
/in/foo.cc:114:9: error: 'int* CArrary<int>::ptr' is private within this context
       a.ptr=tmp;
       ~~^~~
/in/foo.cc:14:8: note: declared private here
     T* ptr;
        ^~~

信息

递交者
类型
自测
题目
P1012 模板--数组交换
语言
C++
递交时间
2020-04-04 16:58:38
评测时间
2020-04-04 16:58:38
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes