小编Tom*_*mek的帖子

c ++ operator []重载问题(工作正常但不是指针,为什么?)

在c ++中运算符[]的问题,我有一些类:

197 class Permutation{
198         private:
199                 unsigned int* array;
200                 unsigned int size;
201
202                 void fill(){
203                         for(unsigned int i=0;i<size;i++)
204                                 array[i]=i;
205                 }
206                 void init(const unsigned int s){
207                         if(s){
208                                 array=new unsigned int[s];
209                                 size=s;
210                         }else{
211                                 size=0;
212                                 array=0;
213                         }
214                 }
215                 void clear(){
216                         if(array){
217                                 delete[]array;
218                                 array=0;
219                         }
220                         size=0;
221                 }
222         public:
223                 Permutation(const unsigned int& s=0):array(0),size(0){
224                         init(s);
225                         fill();
226                 }
227 …
Run Code Online (Sandbox Code Playgroud)

c++ operator-overloading operators

3
推荐指数
1
解决办法
296
查看次数

标签 统计

c++ ×1

operator-overloading ×1

operators ×1