本文介绍了特定于gcc 4.5的C ++数组创建问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码适用于gcc版本2.9至4.4,但不适用于版本4.5:

The following code works under gcc versions 2.9 through 4.4 but not version 4.5:

 struct Pass {
 };

 int main(void){
 Pass **passes = new ( Pass (*[ 10 ]) );
 }

gcc 4.5的特定错误信息是:

The specific error message with gcc 4.5 is:

prob.cc: In function ‘int main()’:
prob.cc:6:31: warning: lambda expressions only available with -std=c++0x or -std=gnu++0x
prob.cc:6:38: error: no matching function for call to ‘Pass::Pass(void (&)())’
prob.cc:2:1: note: candidates are: Pass::Pass()
prob.cc:2:1: note:                 Pass::Pass(const Pass&)

添加请求的标志会使初始警告静音,但不能解决问题。有人可以解释如何解决这个问题吗?这是从一些晦涩的C ++代码我保持,我知道只有有限的C ++。

Adding the requested flag silences the initial warning but does not fix the issue. Could someone explain how to fix this? This is from some obscure piece of C++ code I'm maintaining and I know only a limited amount of C++.

推荐答案

Pass** passes = new Pass*[10];

这篇关于特定于gcc 4.5的C ++数组创建问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 11:25