简体   繁体   English

如何有效地从 function 返回 vector.data() 指针

[英]How to efficiently return vector.data() pointer from a function

Please refer the code请参考代码

class vec {

public: // Want a function here

private:
std::vector<int> abc;

};

I want a public member function, which efficiently returns vector pointer [using abc.data() or any other method will do].我想要一个公共成员 function,它有效地返回向量指针 [使用 abc.data() 或任何其他方法都可以]。 How can I write the function?如何编写 function?

const int * func const {return abc.data();}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM