小编ses*_*esh的帖子

从c ++中的函数返回数组的向量

我必须从函数返回向量.我尝试返回值并将其作为参考传递.但我得到了垃圾值.以下程序给出以下输出.

 **This is the print inside the function**
 1 7 8  
 1 2 3 
 4 5 6 

 **This is the print using the return value /  referenced value outside the function**. 
 1 7 8 
 46980021526656 46980019425190 0 
 1 46980021526656 6

#include <iostream>
#include<vector>
using namespace std;

void process(vector<unsigned long long int*> &vec)
{
    //vector<unsigned long long int*> vec;
    unsigned long long int a[] ={1,2,3};
    unsigned long long int b[] = {4,5,6};
    vec.push_back(a);
    vec.push_back(b);

    for (int i = 0;i < vec.size();i++) …
Run Code Online (Sandbox Code Playgroud)

c++ stl vector

0
推荐指数
1
解决办法
108
查看次数

标签 统计

c++ ×1

stl ×1

vector ×1