向量Vector 应用例子
#include <iostream> #include "Vector.h" int main() { using namespace std; Vector<double> v; cout << v.size() << endl; cout << v.capacity() << endl; v.reserve(20); for(int i = 0, i < 20, i++) v.push_back(double(i)); v[2] = 0.5; //v.operator[ ](2) = 0.5; v.pop_back(); cout << v.size() << endl; cout << v.capacity() << endl; Vector<double>::Iterator first = v.begin(); Vector<double>::Iterator last = v.end(); for( ; first != last; ++first) cout << *first <<endl; } |
|
来自: BUPT-BYR > 《cpp类模板及树相关》