2023年4月16日

摘要: #include <iostream> #include <chrono> #include <thread> void printNumbers1() { for (int i = 1; i <= 10000; i++) { std::cout << "Thread 1: " << i << st 阅读全文
posted @ 2023-04-16 14:59 Z_Chan 阅读(37) 评论(0) 推荐(0)
摘要: auto 是 C++11 中新增的一种类型推导关键字,可以根据变量的初始化表达式,自动推导出相应的类型。使用 auto 可以简化代码,减少类型错误的发生,提高代码的可读性和可维护性。 下面是 auto 的使用示例,假设我们有一个整数变量 x,可以这样使用 auto 进行类型推导: auto x = 阅读全文
posted @ 2023-04-16 14:49 Z_Chan 阅读(26) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> int main() { std::vector<std::string> con; con.push_back("9999"); std::cout<<con[0]; return 0; } vector搞了一个多态,你可 阅读全文
posted @ 2023-04-16 14:35 Z_Chan 阅读(53) 评论(0) 推荐(0)
摘要: 这个也是和Java不同的地方,作用是为了防止类的名字冲突 #include <iostream> namespace myspace{ class A{ public: std::string head; private: std::string body; }; } namespace myspa 阅读全文
posted @ 2023-04-16 14:15 Z_Chan 阅读(20) 评论(0) 推荐(0)
摘要: 这个是用来include的防止多次重复include #ifndef A_H #define A_H int test(){ } #endif 阅读全文
posted @ 2023-04-16 14:03 Z_Chan 阅读(17) 评论(0) 推荐(0)
摘要: #include <iostream> class A{ public: std::string head; private: std::string body; }; int main() { A a; a.head="888"; a.body="999"; return 0; } 报错结果 ma 阅读全文
posted @ 2023-04-16 13:37 Z_Chan 阅读(16) 评论(0) 推荐(0)
摘要: #include <iostream> class A{ public: std::string head; void hello(std::string str){ std::cout<<str<<head<<std::endl; } }; int main() { A a; std::strin 阅读全文
posted @ 2023-04-16 13:29 Z_Chan 阅读(14) 评论(0) 推荐(0)

导航