Return an array from a C++ function -


My question is the same, but it is not that it is an input array, then the array returns. My input is integers, and returns are array.

I have an array that receives some numbers, and makes it an array.

  int makearr (int a, int b, int c) {arr [2] = {a, b, c}; Return? // How can I return it} int main () {// and use it? }   

I want everyone to array and display it.

Note: Sorry, my software does not support Tupless.

A vector ?

  template & lt; Typename T & gt; Std :: vector & lt; T & gt; Manufacturer (TA, TB, TC) {TD [] = {A, B, C}; Return std :: vector & lt; T & gt; (D, D + 3); } Std :: vector & lt; Int & gt; X = Capricorn (1, 2, 3); // Entry x [i]   

If all types of standard containers are verboton then:

  template & lt; Typename t & gt; Structure three {TD [3]; }; Template & lt; Typename T & gt; From three & lt; T & gt; Manufacturer (TA, TB, TC) {Three & lt; T & gt; D = {{A, B, C}}; Return D; } Three & lt; Int & gt; X = Capricorn (1, 2, 3); // borrowing from xd [i]   

and, I draw this C + + 11 solution together which does not use standard containers:

  Template & lt; Typename t, unsigned N & gt; Straight :: min (i.size (), n), v_); Argh (std :: initializer_list & lt; t & gt; i) {std :: copy_n (i.begin (), std :: min (i.size), v_); } T & amp; Operator [] (int i) {return v_ [i]; } Const T & amp; Operator [] (int i) const {returns v_ [i]; } Private: T v_ [N]; }; Template & lt; Typename t, typename ... type & gt; Auto Producer (T & amp; WoW; Viol, Type & amp; vals) - & gt; Arg and lt; T, 1 + size ... (type) & gt; {Argh & lt; T, 1 + sizeof ... (type) & gt; Arr = {val, vals ...}; Return arr; } Auto X = Macarrier (1, 2, 3); // Access x [i]    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -