随笔分类 - C++
C++的基本使用
摘要:原文链接 1 static关键字 加了 static 关键字的全局变量只能在本文件中使用。 static 定义的静态局部变量分配在数据段上,普通的局部变量分配在栈上,会因为函数栈帧的释放而被释放掉。 1.1 全局静态变量 在全局变量前加上关键字 static,全局变量就定义成一个全局静态变量。 内存
阅读全文
摘要:原文链接 使用C++构建一个二叉树并输出。 输入 输入根节点为10,依次输入6、4、8、14、12、16 代码如下: #include <stdio.h> #include <stdlib.h> #include <vector> #include<iostream> #include <stack
阅读全文
摘要:原文链接 使用C++构建一个二叉树并复制、输出。 程序: #include <stdio.h> #include <stdlib.h> //#include <cstdio> #include <vector> #include<iostream> #include <stack> #include
阅读全文
摘要:原文链接 使用C++代码创建一个链表并输出: #include <stdio.h> #include <stdlib.h> //#include <cstdio> //#include <vector> #include<iostream> #include<cstdlib> using names
阅读全文