9 : length_( n>0 ? n : 0), val_(nullptr)
15 cout <<
"--> " <<
length_ << endl;
21 cout <<
"## " <<
val_ << endl;
31 for (
long long int i=0; i<
length_; i++)
54 for (
long long int i=0; i<
length_; i++)
72 s << endl <<
"MyVector has " << orig.
size() <<
" components" << endl;
73 for (i=0; i<orig.
size(); i++)
MyVector(const long long int n=0)
Allocates a vector with n elements on the heap.
const long long int & size() const
Returns the number of elements.
long long int length_
number of elements
virtual ~MyVector()
Deallocates the heap memory.
MyVector & operator=(MyVector const &orig)
Reallocates the vector with the same elements as vector orig and copies its elements.
double * val_
pointer to allocated memory
ostream & operator<<(ostream &s, MyVector const &orig)