属性 | 有效表达式 |
它是默认可构造的。 | A x; |
它是可复制构造的。 | A x(y); |
这是可分配的副本。 | y = x; |
可以使用相等或不相等运算符对其进行比较。 | a == b; a!= b; |
它可以递增。 | a ++; ++ a; |
可以将其取消引用为右值。 | * a; |
也可以将其取消引用为左值。 | * a = t; |
#include <iostream> #include <fstream> #include <iterator> #include <vector> using namespace std; template<class ForwardIterator> // function template void display(ForwardIterator first, ForwardIterator last) // display function { while(first!=last) { cout<<*first<<" "; first++; } } int main() { vector<int> a; // declaration of vector. for(int i=1;i<=10;i++) { a.push_back(i); } display(a.begin(),a.end()); // calling display() function. return 0; }
1 2 3 4 5 6 7 8 9 10
A==B; // equality operator A!=B; // inequality operator
*A = t; t = *A;
A++; ++A;
A--; // invalid
A==B; // valid A>=B; // invalid
A+2; // invalid A+3; // invalid