【问题标题】:define a named variable in a function call在函数调用中定义命名变量
【发布时间】:2017-11-14 20:13:13
【问题描述】:

代码中有什么问题? 我有:

“错误:'j'之前的预期主表达式”

#include <vector>
using namespace std;

void foo(vector<int>& v){  
}

int main()
{
   foo( vector<int> j);
   return 0;
}

【问题讨论】:

标签: c++ function vector reference parameter-passing


【解决方案1】:

这是无效的:

foo( vector<int> j);

因为你不能在函数调用中定义命名变量......

你的意思是肯定的

int main()
{
    vector<int> j;
    foo(j);
    return 0;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 2018-07-11
    • 2017-06-14
    • 2021-12-21
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    相关资源
    最近更新 更多