摘要: 使用 :: 表示 iterator 是 std::map<std::string, double> 类的成员类型。 点击查看代码 #include <iostream> #include <map> int main() { // 创建一个 map,其中键是字符串,值是浮点数 std::map<st 阅读全文
posted @ 2024-08-27 16:37 北宸于烁 阅读(56) 评论(0) 推荐(0)
摘要: 范围基于for循环是C++11中引入的,简化了遍历数组或容器的代码 点击查看代码 #include <iostream> #include <vector> int main() { std::vector<int> numbers = {1, 2, 3, 4, 5}; // 使用范围基于 for 阅读全文
posted @ 2024-08-27 16:34 北宸于烁 阅读(68) 评论(0) 推荐(0)
摘要: 点击查看代码 #include <iostream> class Singleton { private: // 私有化构造函数,防止外部实例化 Singleton() { std::cout << "Singleton Instance Created!" << std::endl; } // 删 阅读全文
posted @ 2024-08-26 10:21 北宸于烁 阅读(40) 评论(0) 推荐(0)