【发布时间】:2012-05-04 13:56:47
【问题描述】:
我有以下问题:
#include <vector>
#include <iostream>
using namespace std;
class Mat {
public:
typedef vector<float>::size_type size_type;
Mat (size_type k, size_type m)
:data_(k*m){}
inline vector<float> data() const {return data_;}
vector<float> data_;
};
int main(){
Mat f (6, 10);
cout << f.data().size() << " " << f.data().end() - f.data().begin();
}
输出为 60 122。
我还以为整个向量data_被一遍遍的移动了,但是为什么begin() end()在这个操作之后就失效了呢?
【问题讨论】:
-
+1 获取完整示例和精心设计的问题。