07 2024 档案
摘要:#include <iostream> #include <string> namespace { class A { public: void addCount() { ++sumCount; } static int getSumCount() { return sumCount; } priv
阅读全文
摘要:#include <iostream> #include <string> namespace { class A { public: const A& get_self() const { std::cout << "常量版本" << std::endl; return *this; } A& g
阅读全文
摘要:C++ class 和 struct 可以相互继承吗? #include <iostream> #include <string> namespace { class A { public: std::string name = "小明"; }; struct B :public A { int a
阅读全文
摘要: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;
阅读全文
摘要:#include <iostream> #include <string> static void show_msg(std::initializer_list<std::string> str_list) { for (auto beg = str_list.begin(); beg != str
阅读全文
摘要:C++ 数组作为函数参数示例: #include <iostream> static void print(const int* beg, const int* end) { while (beg != end) { std::cout << *beg++ << std::endl; } } sta
阅读全文
摘要:这个是 GPT 回答的,可以运行。 #include <iostream> #include <memory> class Base { public: virtual void show() const { std::cout << "Base class" << std::endl; } vir
阅读全文
摘要:代码示例,主要来自《C++ Primer》,动态内存相关那章内容。 #include <iostream> #include <memory> #include <string> namespace { // 未初始化的智能指针,默认保存的空指针 void def_null_sp_test(); /
阅读全文
摘要:#include <iostream> #include <memory> using namespace std; class A; class B { public: B(shared_ptr<A> a) { pa = a; cout << "B 构造..." << endl; } ~B() {
阅读全文
摘要:Mvvmlight 绑定 ItemSource ▲ 界面 XAML: <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="htt
阅读全文
摘要:XAML: <Window x:Class="WpfApp3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/win
阅读全文
摘要:XAML: <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <StackPanel Grid.Row="0"> <TextBox x:Name="t
阅读全文