使用内部灰泥构建器绘制地图
Map with an inner stuct builder
我有一个内部结构为的映射
struct Messages {
unsigned int id;
string user_name;
string content;
time_t timestamp;
Messages(const string& a_user_name, const string& a_content) :
user_name(a_user_name), content(a_content), id(++last_id)
{
timestamp = time(0);
}
};
map<unsigned int, Messages> Global_messages;
当我尝试以的形式访问元素时
cout << Global_messages[i].id;
这给了我一个错误,没有合适的建设者。
std::map::operator[]
要求该值是默认可构造的,而Messages
则不是这样。您必须使用其他接口insert
/emplace
来填充映射,使用at
或find
来检索值
相关文章:
- 为什么不;名字在地图上是按顺序排列的吗
- 基于多个条件处理地图中的所有元素
- 在C++中将矢量转换为嵌套地图
- QuadTree只在窗口的右上角绘制
- 绘制旋转的三角形
- flutter:即使shouldRepaint()返回true,自定义画家也不会重新绘制
- 如何在QT中的自定义视频小工具t上绘制矩形
- 替换基于地图的所有引用
- 如何区分地图中的 0 和 false?
- 如何在Visual Basic中使用矩形函数OpenGL绘制矩形
- 地图计数确实很重要,或者只是检查是否存在
- 低帧率,仅使用地图和小地图绘制 (SFML)
- 尝试绘制精灵地图时出现 SFML 错误
- Mapbox GL为什么不使用AGG进行地图绘制
- 使用内部灰泥构建器绘制地图
- 简单的地图绘制问题
- OpenGl 在图块地图C++的顶部绘制
- 使用sfml绘制平铺地图
- 绘制小地图(游戏)
- 绘制瓷砖地图正在将我的 fps 降低到爬行