摘要: #include <iostream> #include <string> namespace { class A { public: void addCount() { ++sumCount; } static int getSumCount() { return sumCount; } priv 阅读全文
posted @ 2024-07-19 19:49 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <string> namespace { class A { public: const A& get_self() const { std::cout << "常量版本" << std::endl; return *this; } A& g 阅读全文
posted @ 2024-07-19 14:46 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: C++ class 和 struct 可以相互继承吗? #include <iostream> #include <string> namespace { class A { public: std::string name = "小明"; }; struct B :public A { int a 阅读全文
posted @ 2024-07-19 11:30 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: C++ 返回数组指针简单测试: #include <iostream> static const size_t ARR_SIZE = 10; static int arr[ARR_SIZE]; // 更新数组 #define UPDATE_ARR_DATA(i) for (size_t j = 0; 阅读全文
posted @ 2024-07-18 14:19 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <string> static void show_msg(std::initializer_list<std::string> str_list) { for (auto beg = str_list.begin(); beg != str 阅读全文
posted @ 2024-07-18 13:00 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: C++ 数组作为函数参数示例: #include <iostream> static void print(const int* beg, const int* end) { while (beg != end) { std::cout << *beg++ << std::endl; } } sta 阅读全文
posted @ 2024-07-18 09:16 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 这个是 GPT 回答的,可以运行。 #include <iostream> #include <memory> class Base { public: virtual void show() const { std::cout << "Base class" << std::endl; } vir 阅读全文
posted @ 2024-07-17 17:04 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 代码示例,主要来自《C++ Primer》,动态内存相关那章内容。 #include <iostream> #include <memory> #include <string> namespace { // 未初始化的智能指针,默认保存的空指针 void def_null_sp_test(); / 阅读全文
posted @ 2024-07-17 13:23 double64 阅读(2) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> using namespace std; class A; class B { public: B(shared_ptr<A> a) { pa = a; cout << "B 构造..." << endl; } ~B() { 阅读全文
posted @ 2024-07-16 14:40 double64 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Mvvmlight 绑定 ItemSource ▲ 界面 XAML: <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="htt 阅读全文
posted @ 2024-07-10 13:46 double64 阅读(2) 评论(0) 推荐(0) 编辑