![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
逍遥子墨
烧不死的鸟是凤凰
展开
-
C++初学之例程2
#include using namespace std; //讲解局部变量的作用范围 只在 函数内部 函数结束后局部变量的生命周期 也结束 //真的能实现 值得交换吗?? void swap(int , int ); void realswap(int* ,int*);//这个课以将局部变量的值 改变 //任何在函数外部定义的变量时 全局变量------一般在main函数之外定义原创 2014-01-16 16:07:44 · 769 阅读 · 0 评论 -
C++初学例程4
#include using namespace std; int main() { //三目运算符 int a; int b =4; cout cin>>a; if(a>b) { cout b\n"; }else { cout } //三目运算符 就是实现上面的比较和赋值 int z; z = (a>b)? a:b; /原创 2014-01-16 16:09:47 · 629 阅读 · 0 评论 -
C++初学例程1
#include using namespace std;//使用标准输入输出流 namespace a { int b=1; } namespace b { int b =3; } int show(); int plus(int a,int b);//函数的声明 ---并不分配内存 //免声明的函数 就是写在main函数之前 int main() { int原创 2014-01-16 16:07:41 · 819 阅读 · 0 评论 -
C++初学例程3
#include #include #include//输入输出流文件 using namespace std; void learn_float(); void learn_const(); void learn_enum(); int main() { //计算机中的加减法 都是采用的 补码来完成的 //正数的补码 就是其本身 //负数的补码 两步得到: 1、除符号位 其原创 2014-01-16 16:08:37 · 829 阅读 · 0 评论 -
C++初学例程5---类的定义和类中方法的定义及调用
#include using namespace std; //类的声明 class Human//命名习惯 首字母大写 { //类中方法的编写有两种方式 //1、直接定义 //2、在类中声明 在类外定义 一定要加上该方法是属于哪个类的 //命名规则 是驼峰表示法 public://注意格式 和java 不一样 这里有冒号的 void Set_weight(int w原创 2014-01-16 16:10:36 · 7321 阅读 · 0 评论