摘要: /*//1 函数的重载 普通函数的重载#include <iostream>using namespace std;void func(int);void func(long);void func(float);void func(double);int main(){ int a = 1; long b = 100000; float c = 2.1; double d = 2.1415926; func(a); func(b); func(c); func(d); return 0;}void func(int a){ cout<<"int: a=&quo 阅读全文
posted @ 2012-06-17 22:08 简单--生活 阅读(272) 评论(0) 推荐(0)
摘要: // 1 什么是引用//引用也是C++的初学者比较容易迷惑的,它几乎拥用指针所有的功能,但是语法更加简单//本单我们就来不官瘾引用,并且分清它与指针的区别/*#include <iostream>using namespace std;int main(){ int num; //mum是num的别名,这两个变量是一个变量,只不过 名字不同而已 //这就好像李四有个名号叫李大嘴,大家称呼李四指的是李四这个人,称呼李大嘴也是指李四这个人 //李四和李大嘴都是一个人,只是名字出现了不同 //所以,我们对mum的操作实际就是对num的操作 //这里要注意事项的是,别名mum前面的符号&a 阅读全文
posted @ 2012-06-17 22:06 简单--生活 阅读(201) 评论(0) 推荐(0)
摘要: /*//1 什么是地址#include <iostream>using namespace std;int main(){ int i=0; cout<<&i<<endl; return 0;}*//*// 2 用指针保存地址#include <iostream>using namespace std;int main(){ int i=1; int *p; p = &i; cout<<"&i:"<<&i<<endl; cout<<"p: 阅读全文
posted @ 2012-06-17 22:04 简单--生活 阅读(224) 评论(0) 推荐(0)
摘要: /*// 1 循环语句的老祖宗Goto语句#include <iostream>using namespace std;int main(){ int i= 1; if(i > 10){ //goto yes; } cout<<"*"<<i<<endl; i++; //goto yes; cout<<"程序结束"; cout<<"********\n";yes:; return 0;}*//*// 2 while语句#include <iostream 阅读全文
posted @ 2012-06-17 22:01 简单--生活 阅读(170) 评论(0) 推荐(0)
摘要: /*// 4 声明一个类#include <iostream>using namespace std;class Human{public: void GetStature(); void getWeight();private: int stature; int weigth;};int main(){ return 0;}*//*//6 定义一个对像#include <iostream>using namespace std;class human{public: void getStartue(){cout<<startue; } void setSt 阅读全文
posted @ 2012-06-17 22:00 简单--生活 阅读(207) 评论(0) 推荐(0)
摘要: /*// 4 什么是表达式#include <iostream>using namespace std;int main(){ for(int i=0; i<=60; i++) { if(i%6 == 0) { cout<<"\n"; } cout<<i<<"\t"; } return 0;}*//*// 5 赋值运算符与数学运算符#include <iostream>using namespace std;int main(){ int a=2; a = a *= 6; cout< 阅读全文
posted @ 2012-06-17 21:58 简单--生活 阅读(1087) 评论(0) 推荐(0)
摘要: //1 C++数据类型#include <iostream>int add(int x, int y){ return x+y;}int main(){ int i=1, y=2; std::cout<<add(i,y); return 0;}// 2什么是变量#include <iostream>using namespace std;int main(){ int a = 35; cout<<"a的值是:"<<a<<endl; cout<<"请输入数值:"<&l 阅读全文
posted @ 2012-06-17 21:56 简单--生活 阅读(249) 评论(0) 推荐(0)
简单--生活(CSDN)