
Cpp
htj10
这个作者很懒,什么都没留下…
展开
-
wchar_t* 与 char* 互转
std::wstring CharToWchar(const char* c, size_t m_encode = CP_ACP){ std::wstring str; int len = MultiByteToWideChar(m_encode, 0, c, strlen(c), NULL, 0); wchar_t* szBuf = new wchar_t[len + 1]; MultiByteToWideChar(m_encode, 0, c, strlen(c), szBuf, len);原创 2021-03-18 21:52:45 · 162 阅读 · 0 评论 -
二叉树的先、中、后、层次 遍历的模板
文章目录先序遍历(NLR)中序遍历(LNR)后序遍历(LRN)层次遍历struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { }}先序遍历(NLR)递归版本void preOrder(TreeNode* root){ if (!root) return; // proces原创 2020-12-28 21:48:28 · 157 阅读 · 0 评论 -
复制构造函数VS赋值操作符重载
class Student{public : Student(){ cout << "构造函数\n"; } ~Student(){ cout << "析构函数\n"; } //复制构造函数 Student(const Student& s) { cout << "复制构造函数\n"; } //赋值操作符重载 Student& operator=(Student& s){ cout << "赋值操作符重原创 2020-12-05 09:30:26 · 242 阅读 · 0 评论