小编sac*_*amm的帖子

在c ++中返回一个std :: vector

编辑

*请提出这个主题,因为我在这个论坛上不能再提问了.编程就是我的生活,我因为自动禁止而陷入困境.谢谢(或者我需要主持人的帮助来解决这个问题*

我是c ++的初学程序员,我想基本上返回一个std::vector 当我调试我的代码时,我得到函数调用缺少参数列表.这是我的简单代码

谢谢你的帮助

#include "stdafx.h"
#include <vector>
#include <iostream>

static std::vector<int> returnStaticVector();

static std::vector<int> returnStaticVector(){
    std::vector<int> vectorInt = std::vector<int>();
    vectorInt.push_back(0);
    return vectorInt;

}

int _tmain(int argc, _TCHAR* argv[])
{
    std::vector<int> a = std::vector<int>();

    a = returnStaticVector(); // Compile , but error when I try to access to the size of the std::vector

    //int size = a.size; //error C3867: 'std::vector<int,std::allocator<_Ty>>::size': function call missing argument list; use '&std::vector<int,std::allocator<_Ty>>::size' to create a pointer to member  
    //int size = &a.size; …
Run Code Online (Sandbox Code Playgroud)

c++ vector return-value c++11

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

标签 统计

c++ ×1

c++11 ×1

return-value ×1

vector ×1