75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
#include <iostream>
|
|
#include <Windows.h>
|
|
|
|
// class WndTest : public Wndbase<WndTest> {
|
|
// public:
|
|
// static PCWSTR CLASSNAME() {return L"TestWndClass";}
|
|
// static void UpdateWnd(){};
|
|
// LRESULT WndProc(UINT msg, WPARAM wparam, LPARAM lparam) override {
|
|
// switch (msg) {
|
|
// case WM_DESTROY: {
|
|
// PostQuitMessage(0);
|
|
// return 0;
|
|
// }
|
|
// default: {
|
|
// return DefWindowProc(hwnd_, msg, wparam, lparam);
|
|
// }
|
|
// }
|
|
// }
|
|
// protected:
|
|
// bool EDGEMODE() override { return false; }
|
|
//
|
|
// };
|
|
//
|
|
//
|
|
// int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int nShowCmd) {
|
|
//
|
|
// WndTest test{};
|
|
// test.Init(hInstance, L"test window");
|
|
// test.Exec(nShowCmd);
|
|
//
|
|
// return 0;
|
|
// }
|
|
|
|
|
|
|
|
class Test {
|
|
static int id;
|
|
|
|
public:
|
|
Test() {
|
|
std::cout << "[" << id++ << "] 构造器" << std::endl;
|
|
}
|
|
Test(const Test &other) {
|
|
std::cout << "[" << id++ << "] 拷贝构造" << std::endl;
|
|
}
|
|
Test &operator=(const Test &oter) {
|
|
std::cout << "[" << id++ << "] 拷贝赋值" << std::endl;
|
|
return *this;
|
|
}
|
|
Test(Test &&other) noexcept {
|
|
std::cout << "[" << id++ << "] 移动构造" << std::endl;
|
|
}
|
|
Test &operator=(Test &&other) noexcept {
|
|
std::cout << "[" << id++ << "] 移动赋值" << std::endl;
|
|
return *this;
|
|
}
|
|
int t{};
|
|
};
|
|
|
|
int Test::id = 0;
|
|
|
|
|
|
void test(Test t) {
|
|
t.t = 887;
|
|
std::cout << "in test function , t=" << t.t << std::endl;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
SetConsoleOutputCP(CP_UTF8);
|
|
|
|
Test t{};
|
|
test(std::move(t));
|
|
std::cout << "回到main,此时t=" << t.t << std::endl;
|
|
}
|