2016/10/3
来源:互联网 发布:比特大陆 知乎 编辑:程序博客网 时间:2024/06/03 18:45
*/1631-5 黄加勉 <2016.10.3>
连续第2天总结*/
namesapce A(今日任务)
{
1.const及其用法(100%);
2.函数重载(100%);
3.温习一下指针和引用(80%);
}
namespace B(具体内容)
{
之前一直以为const是一个变量类型,现在才发现应该是修饰一个变量的,使它变成常量;
函数重载是个好东西;
比起用命名空间,重载感觉更高效(目前来说是),起码不用再打一堆namespace XXX和::了;
而且有函数重载的功能感觉可读性更强了,一个print想打啥都行;
}
//附上代码:
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
typedef struct
{
char x;
char y;
}coord;
void print(int a);
void print(coord b);
void print(double x);
void print(int arr[]);
void print(unsigned int k, char l);
int main(void)
{
system("color F0");
const double pi = 3.14159265358979;
int arr[5] = { 1,2,3,4,5 };
int r = 1;
int *p = &r;
int *&q = p;
int **m = &q;
int **&n = m;
int ***a = &n;
int ***&b = a;
int ***&o = b;
***o = 486;
coord A;
A.x = 'B';
A.y = 'C';
print(A);
print(10);
print(arr);
print(pi);
print(r, 'w');
system("pause");
}
void print(int a)
{
cout << a << endl;
}
void print(coord b)
{
cout << b.x <<","<<b.y<< endl;
}
void print(double x)
{
cout << setprecision(15) << x << endl;
}
void print(int arr[])
{
for (int i = 0; i < 5; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
void print(unsigned int k, char l)
{
cout << k * 10 << endl;
}
/*还有:vc6.0以后用“include<iostream>;using namespace std;”!!!!!!!!!!!!!!!
#include<iostream.h>不能通过!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
血的教训!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
*/还有:cout默认输出double精度是六位
加<< setprecision(n)(n为精度) 就可以控制输出精度了
另外还要加#include <iomanip>,也是在std里面的,没有.h的后缀*/
namespace C
{
1.内存管理;
2.类和对象了解一下;
}
连续第2天总结*/
namesapce A(今日任务)
{
1.const及其用法(100%);
2.函数重载(100%);
3.温习一下指针和引用(80%);
}
namespace B(具体内容)
{
之前一直以为const是一个变量类型,现在才发现应该是修饰一个变量的,使它变成常量;
函数重载是个好东西;
比起用命名空间,重载感觉更高效(目前来说是),起码不用再打一堆namespace XXX和::了;
而且有函数重载的功能感觉可读性更强了,一个print想打啥都行;
}
//附上代码:
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
typedef struct
{
char x;
char y;
}coord;
void print(int a);
void print(coord b);
void print(double x);
void print(int arr[]);
void print(unsigned int k, char l);
int main(void)
{
system("color F0");
const double pi = 3.14159265358979;
int arr[5] = { 1,2,3,4,5 };
int r = 1;
int *p = &r;
int *&q = p;
int **m = &q;
int **&n = m;
int ***a = &n;
int ***&b = a;
int ***&o = b;
***o = 486;
coord A;
A.x = 'B';
A.y = 'C';
print(A);
print(10);
print(arr);
print(pi);
print(r, 'w');
system("pause");
}
void print(int a)
{
cout << a << endl;
}
void print(coord b)
{
cout << b.x <<","<<b.y<< endl;
}
void print(double x)
{
cout << setprecision(15) << x << endl;
}
void print(int arr[])
{
for (int i = 0; i < 5; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
void print(unsigned int k, char l)
{
cout << k * 10 << endl;
}
/*还有:vc6.0以后用“include<iostream>;using namespace std;”!!!!!!!!!!!!!!!
#include<iostream.h>不能通过!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
血的教训!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
*/还有:cout默认输出double精度是六位
加<< setprecision(n)(n为精度) 就可以控制输出精度了
另外还要加#include <iomanip>,也是在std里面的,没有.h的后缀*/
namespace C
{
1.内存管理;
2.类和对象了解一下;
}
1 0
- 2016/10/3
- 2016/10/3
- CVPR 2016-10-3
- 2016年3月10号
- 2016-3-10 UNIX 多进程多线程socket编程
- 2016年3月10日设计日志
- 2016年3月18日10:11:36
- 【Test 2016-10-3】栈/分治+Trie+spfa最短路
- PAT(A) 101-140-3-2016-12-10 考试总结
- C#和.NET 2.0实战(2016-3-18 15:17、2016-4-21 10:08)
- CVPR 2016-10-10
- 2016-10-10
- 2016/10/10
- 1613-3-傅溥衍 总结《2016年10月10日》【连续第十天总结】
- 2016年3月3日10:26:15 大一下学期开学第一周。
- 1613-3-傅溥衍 总结《2016年10月3日》【连续第三天总结】
- 1622-5 孔富晨 总结《2016年10月3日》【连续3天总结】
- 2016/10/01,2016/10/02
- ARM集成opencv
- Linux下的shell编程(六)--函数,重定向,文件
- ASCII码排序
- Python爬虫入门学习例子之糗事百科
- Linux(ubuntu)下java的安装和配置
- 2016/10/3
- hdu2553n皇后问题
- 开灯问题
- 优化SQL语句的一般步骤①
- Activity退出后,键盘不收回
- 面试编程题:(一)数字规律
- java.net.SocketException: Connection reset 解决方法
- HDU 5907 Find Q
- 2.6.1节练习