Can I return an array by value in C++? By value I mean returning a copy instead of using a pointer. If so can someone provide an example of returning a 1d array and a 2d array?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No; you can return arrays by value only by wrapping them inside a
structor aclass(actually, you can simply return an appropriate instance ofstd::array, which encapsulates a C-style array inside a template class which provides also some bells and whistles).