c++ - 生成唯一 ID C++
问题描述
我想为我的复杂结构生成一个唯一标识符“ident”,我该怎么做?
在我的标题中,复杂的结构是:
struct Complexe {
float x;
float y;
static unsigned int ident;
};
void Init(Complexe&);
etc...
在 cpp 文件中,我需要为 ident 赋予一个唯一的 int
Init(Complexe&z){
z.ident = 0;
z.y = 0;
z.x = 0;
};
解决方案
考虑 UUID,特别是 GNU/Linux 上的 uuid_generate,或者(似乎)Windows 上的 UuidCreate。
推荐阅读
- reactjs - React Micro 前端架构设计
- css - 如何将引导导航栏切换按钮与品牌名称的左侧或右侧对齐?
- swift - Swift+Firestore - 从 getDocument() 函数返回
- api - 从开发控制台更改 YouTube 分辨率
- java - 如何知道它是否是 SpringBatch 的 ItemProcessor 中的最后一项
- api - 当在 initState() 中调用未来方法时,使用 Future Builder 调用 Flutter API 会返回错误
- python - 无法访问 JIRA 项目的“来自”属性
- python - 在 python 3.5 中 pip install json2html 不起作用
- django - Django - 基于类的视图 - 模型中的元标记不会传递给模板
- bash - 在 bash 脚本中将日志文件读入 2D/1D 数组