如何解决问题“错误:在顶层无效使用'this'”?

问题描述 投票:1回答:1

我试着在文章Adding Multiple Interface Support in NS-2之后在ns2中添加多接口。更改文件channel.cc时,我在下面添加代码:

nextX_[this−>index()]
prevX_[this−>index()]

进行此更改后,我收到以下错误:

In file included from mac/channel.cc:67:    
mac/wireless-phyExt.h: At global scope:    
mac/wireless-phyExt.h:70: warning: ‘typedef’ was ignored in this declaration    
mac/wireless-phyExt.h:255: warning: ‘typedef’ was ignored in this declaration    
mac/channel.cc:70: error: invalid use of ‘this’ at top level    
mac/channel.cc:70: error: array bound is not an integer constant    
mac/channel.cc:71: error: expected constructor, destructor, or type conversion before ‘prevX_’    
make: *** [mac/channel.o] Error 1

这些是什么意思?

c++ ns2
1个回答
0
投票

我对你的帖子进行了一些编辑,以便它更有意义,并添加了我认为你正在引用的文章的链接。看起来您可能在文件中的错误位置添加了建议的代码行,尽管引用的文章并不是关于它应该去哪里的具体内容,也没有提供有关上下文的更多信息。改变或整个项目应该做什么,所以我被迫试图为您提供进一步的信息。此外,我会确保您不直接复制和粘贴pdf文件中的代码,因为它似乎在字符之间放置了额外的空格。最后,C ++中的一行代码需要以';'结尾你没有说明你是否做得恰到好处。

© www.soinside.com 2019 - 2024. All rights reserved.