摘要:
struct tagItem
{
int a;
int b;
}
//假如在A类中定义成员:
vector<tagItem> m_vecItem;
vector<tagItem> A::f()
{
return m_vecItem;//tagItem需要定义拷贝构造函数,否则m_vecItem即使在别处push_back了,每一个元素的a,b成员不会拷贝过去而保持初值(0之类的值)
} vector<tagItem>& A::f()
{
return m_vecItem;
}
因为stl容器都是基于拷贝,故不仅是vector,其它容器返回引用或对象都 阅读全文
posted @ 2011-11-29 21:20
Hibernate4
阅读(959)
评论(0)
推荐(0)

浙公网安备 33010602011771号