在cpp头文件中使用外部变量
Using extern variables in a Cpp-header
我在cpp的头文件中使用外部变量有一些问题。
所以我有我的(简化)cppfiles如下:
<标题> Header.h h1> MainFile.cpp h1> Casual.cpp h1> 在当我编译这个的时候,它会编译。但是在运行程序时,它会中止告诉我CXX0030:错误:表达式不能求值
有谁知道是什么问题吗?
在CalculateHeight定义的Casual.cpp中出现错误。这行写着:
coordinates.push_front(Point(x,y,root->data));
标题>
添加
定义后BstNode* GetNewNode( int d ){
BstNode* res = new BstNode();
res->data = d;
return res;
}
程序执行:
Creating test-structure...
Width: 6
checkcheck(3,-1)
(2,-1)
(1,-1)
(3,1)
(2,1)
(1,1)
(5,0)
(4,0)
(3,0)
(2,0)
(1,0)
(0,0)
Height: 3
我没有验证这个;-)
相关文章:
- 如果全局变量默认是外部变量,为什么要添加"extern"关键字?
- 堆栈/帧指针作为外部变量
- const_cast const 方法中的"this"将"this"分配给外部变量?
- 外部变量的初始化
- 如何在命名空间中初始化外部变量
- 将全局外部变量的私有版本与 OpenMP 结合使用
- 使用外部变量会导致"unsigned char"错误LNK2001
- 为什么通过复制捕获 lambda 具有与外部变量相同的地址
- 我们是否应该在项目中包含的所有文件中声明外部变量
- 如何将 Wifi.localIP() 转换为字符串并将其存储到外部变量
- 具有仅在某些情况下引用外部变量的属性的类
- C 中的外部变量
- Xcode C++外部变量链接器错误
- 使用外部变量时的多重定义错误
- C 和 C++ 中的外部变量有什么区别
- 默认情况下,非常量变量不被视为外部变量吗?
- 当外部变量在其他文件中声明不同时,如何使G 产生警告
- 是初始化为其默认值的外部变量
- 将外部变量传递给类 c++
- C++中有更多的类和外部变量