This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | Next revision Both sides next revision | ||
|
cpp:vector_overloading [2017/05/12 05:02] gthanos |
cpp:vector_overloading [2019/05/16 07:29] gthanos |
||
|---|---|---|---|
| Line 9: | Line 9: | ||
| class Vector { | class Vector { | ||
| int *array; | int *array; | ||
| - | | + | int size; |
| | | ||
| public: | public: | ||
| - | Vector(unsigned | + | Vector(int length=0); |
| Vector(const Vector &v); | Vector(const Vector &v); | ||
| Vector(const Vector *v); | Vector(const Vector *v); | ||
| ~Vector(); | ~Vector(); | ||
| - | | + | int length() const;// return Vector' |
| - | int & | + | int & |
| int find(int a) const; | int find(int a) const; | ||
| // if not element not found | // if not element not found | ||
| Line 24: | Line 24: | ||
| }; | }; | ||
| - | Vector:: | + | Vector:: |
| size = length; | size = length; | ||
| array = new (nothrow) int[size]; | array = new (nothrow) int[size]; | ||
| Line 61: | Line 61: | ||
| } | } | ||
| - | unsigned | + | int Vector:: |
| return size; | return size; | ||
| } | } | ||
| - | int & | + | int & |
| if(pos> | if(pos> | ||
| cerr << " | cerr << " | ||