Xcode 不链接两个结构
Xcode not linking two structures?
为什么Xcode说"Vertex.h"无法识别?
//Vertex.h
#include "Edge.h"
struct Vertex
{
vector<Edge> adjList;
string myData;
};
在单独的文件中,
//Edge.h
#include "Vertex.h"
struct Edge
{
Vertex* destination; // "Unknown type named 'Vertex.h'
double weight;
}
这里有错误吗?请帮忙。谢谢!
你有一个循环依赖:Vertex.h
取决于Edge.h
取决于Vertex.h
......
在您的特定情况下,这很容易解决,因为Edge.h
不需要Vertex
的完整定义,只知道Vertex
结构存在,因此请像更改它一样
//Edge.h
struct Vertex;
struct Edge
{
Vertex* destination; // "Unknown type named 'Vertex.h'
double weight;
};
更改是不包含Vertex.h
,而是声明Vertex
结构。这告诉编译器存在一个名为Vertex
的结构,因此它可以用于例如指针或引用。
相关文章:
- 在两个结构之间共享数组
- C++ 如何从函数传递两个结构?
- 如何认为两个结构相等,而不管它们的第二个属性如何?
- 使用用户函数在 C++ 中交换两个结构
- 在CPP中互相访问的两个结构
- 如何实现 std::map::查找包含两个结构'Pos'结构的比较逻辑,每个结构包含 x 和 y 坐标
- 当我们在两个结构上使用它时,= 运算符会做什么
- 合并/连接两个结构
- C++(SDL2)中的碰撞函数.如何传递存储在不同向量中的两个结构
- 具有相同名称和不同模板参数的两个结构如何工作
- 复制两个结构指针时出现分段错误
- Xcode 不链接两个结构
- 在两个结构(函子)中理解typedef的作用域
- 如何在c++中比较两个结构字符串
- 设置两个结构体相等后,指针为NULL
- 如何声明具有other类型成员的两个结构体
- 如何在c++中连接两个结构体类型变量
- C++ stl 列出了两个结构交叉引用
- 有两个结构在C++中相互引用彼此的变量
- 为什么我的两个结构数组没有相互作用?