简体   繁体   English

Netbeans C ++返回类型的模板化函数

[英]Netbeans C++ return type of templated functions

For some reason the code completion in netbeans can't figure out the return type of templated functions. 由于某种原因,netbeans中的代码完成无法确定模板化函数的返回类型。 Take the following example... 以下面的例子为例......

struct Test
{
   int val;
};

int main()
{
     vector<Test> v;
     Test t = {10};
     v.push_back(t);
     cout << v[0].val;  //Netbeans gives the warning "Unable to resolve identifier val"
     return 0;
}

The code compiles and runs fine but what is annoying is that I get this error all over my code when I use vectors. 代码编译并运行正常,但令人讨厌的是,当我使用向量时,我在代码中得到了这个错误。 Also the code completion does not seem to work. 代码完成似乎也不起作用。 When I type v[0]. 当我输入v [0]时。 there is no drop down giving me to option to choose val. 没有下拉让我选择val。

I am using netbeans 7.4 along with 64bit MinGW. 我使用netbeans 7.4和64bit MinGW。

Well there seems to bug in the Netbeans 7.2 version and later it was fixed. 好吧,在Netbeans 7.2版本中似乎有bug,后来它被修复了。

https://netbeans.org/bugzilla/show_bug.cgi?id=172227 https://netbeans.org/bugzilla/show_bug.cgi?id=172227

You can find the complete discussion and possible resolution on the same problem from the following link. 您可以从以下链接找到有关同一问题的完整讨论和可能的解决方案。 Here you can find how to resolve this problem(possibly). 在这里,您可以找到解决此问题的方法(可能)。

Netbeans 7.2 shows "Unable to resolve identifier" , although build is successful 虽然构建成功,但Netbeans 7.2显示“无法解析标识符”

按照以下链接执行一些简单的步骤来解析标识符, Netbeans 7.2显示“无法解析标识符”,尽管构建成功 1

try changing 尝试改变

struct Test
{
   int val;
};

with

typedef struct
{
    int val;
} Test;

in pure C "Test" would not be a defined type but "struct Test" would be. 在纯C中,“Test”不是定义的类型,而是“struct Test”。 By changing to a typedef then you then have "Test" as a defined type. 通过更改为typedef,然后将“Test”作为已定义的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM