【发布时间】:2012-03-24 02:15:49
【问题描述】:
Dev-C++ 有什么问题,或者我的代码中有关于使用引用变量的错误?
#include <stdio.h>
struct P {
int x;
};
int main(int argc, char **argv){
struct P Point[5];
struct P & rPoint;
int i;
for(i=0;i<=4;i++) {
rPoint = Point[i]; // I know. I can use Point[i].x = i. But...
rPoint.x = i;
}
for(i=0;i<=4;i++) {
rPoint = Point[i];
printf("%d\n", rPoint.x);
}
system("pause");
return 0;
}
错误: 9 C:***\main.c '&' 标记前的语法错误
【问题讨论】:
-
我不认为有 Dev-C++ 特定的库,重要的是编译器,而对于 Dev-C++,您通常只使用旧版本的 MinGW(这与通常在其他免费且更好的 IDE)。
-
$ gcc test.cpp test.cpp: In function 'int main(int, char**)': test.cpp:9:20: error: 'rPoint' 声明为引用但未初始化test.cpp:21:22: 错误:“系统”未在此范围内声明
-
我无法在 mingw 上构建库。该库即将在 Dev-C++ 上打包。有点懒惰:)
-
AFAIK Dev-C++ 只是一个 IDE,背后的编译器是 gcc 并且没有与 Dev-C++ 捆绑的特殊非标准库(但也许我错了)。无论如何,这是 C 和 C++ 的混合体,我会说它是纯 C 语言,使用了 C++ 的一个特性,但没有真正的 C++ 语言;我坚信
system("pause")的使用是一种糟糕而邪恶的编程习惯,即使对于 Windows 程序员也是如此...... -
你有 devpaks 库吗?无论如何,您不需要特定的 IDE 来使用预编译的动态或静态库。