2018.9.30学习记录

1.https://zhidao.baidu.com/question/181081049.html

typedef常见用法

1.常规变量类型定义

例如:typedef unsigned char uchar
描述:uchar等价于unsigned char类型定义 uchar c声明等于unsigned char c声明

2.数组类型定义
例如: typedef int array[2];
描述: array等价于 int [2]定义; array a声明等价于int a[2]声明

扩展: typedef int array[M][N];
描述: array等价于 int [M][N]定义; array a声明等价于int a[M][N]声明

3.指针类型定义
例如: typedef int *pointer;
描述: pointer等价于 int *定义;pointer p声明等价于int *a声明

例如: typedef int *pointer[M];
描述: pointer等价于 int *[M]定义 pointer p声明等价于int *a[M]声明明

4.函数地址说明
描述:C把函数名字当做函数的首地址来对待,我们可以使用最简单的方法得到函数地址
例如: 函数:int func(void); unsigned long funcAddr=(unsigned long)func, funcAddr的值是func函数的首地址

5.函数声明
例如: typedef int func(void); func等价于 int (void)类型函数
描述1: func f声明等价于 int f(void)声明,用于文件的函数声明
描述2: func *pf声明等价于 int (*pf)(void)声明,用于函数指针的生命,见下一条

6.函数指针
例如: typedef int (*func)(void)
描述: func等价于int (*)(void)类型
func pf等价于int (*pf)(void)声明,pf是一个函数指针变量

7.识别typedef的方法:
a).第一步。使用已知的类型定义替代typdef后面的名称,直到只剩下一个名字不识别为正确
如typedef u32 (*func)(u8);
从上面的定义中找到 typedef __u32 u32;typedef __u8 u8
继续找到 typedef unsigned int __u32;typedef unsigned char __u8;
替代位置名称 typedef unsigned int (*func)(void);
现在只有func属于未知。
b).第二步.未知名字为定义类型,类型为取出名称和typedef的所有部分,如上为
func等价于unsigned unsigned int (*)(unsigned char);
c).第三部.定义一个变量时,变量类型等价于把变量替代未知名字的位置所得到的类型
func f等价于unsigned unsigned int (*f)(unsigned char)

 

typedef的语法规则其实很简单,一句话来说就是定义对象的语法前加关键字typedef,剩下的不变,原本定义的对象标识符换成类型标识符,对应语义从定义一个对象改成定义一个类型别名。typedef看起来复杂根本原因是对象定义的语法比较复杂,例如分隔符*和[]的用法。
typedef struct node{
datatype data;
struct node *lchild,*rchild;
}bintnode;
对应的对象定义:
struct node{
datatype data;
struct node *lchild,*rchild;
}bintnode;
去除bintnode来看就是一个类型struct node的完整描述。加上了bintnode来看,表示定义了一个struct node类型的对象bintnode。
现在前面有typedef,因此这个bintnode不是对象名而是类型名。也就是定义了一个类型别名bitnode,实际上指的就是struct node这个完整类型。
typedef定义的类型别名在作用域内和被定义的原类型语义上等价,都是表示同一个类型的名称。这里typedef之后bitnode可以和struct node互相代替(注意在C++中,如果同一命名空间内类型名和对象名没有重复,那么struct可以省略,struct node等价于node)。
更复杂一点的:
struct node{
datatype data;
struct node *lchild,*rchild;
}bintnode, *bintree;
注意定义对象时*修饰对象本身而不是修饰类型。因此这里定义了struct node对象bintnode和struct node*类型的对象bintree。
对应的类型定义:
struct node{
datatype data;
struct node *lchild,*rchild;
}bintnode, *bintree;
这里定义了类型别名bintnode表示完整类型struct node,以及bintree表示类型struct node*。
拆开来就成了
typedef struct node{
datatype data;
struct node *lchild,*rchild;
}bintnode;

typedef bintnode *bintree;
这种写法看起来应该稍微清楚了一点。
至于下面的cirqueue,和上面的bintnode类似,只是这里省略了结构体名称,是一个匿名类型。这样写的主要好处是类型名可以省略struct(C++里面不这样写也可以省略)。

 

2.https://blog.csdn.net/doitsjz/article/details/50073231  UDT协议的介绍,应该没事看看

3.ofstream fout,fout<<"输出到文件中";;;;;ifstream fin; fin>>buffer;从fin输入,到buffer中

string filename("D:\\test\\testfile");ifstream infile(filename);string line;while(infile>>line){m_set.insert(line)};

 #ifndef _WIN32

就可以定义linux系统下的一些操作,还得回头复习 一下,linux下为什么要屏蔽那些信号,所以信号那张也得好好看呀,还得装linux操作系统

#endif

 

3.#define LOG4Z_DEFAULT_PATH "./log/"  true 可以这样定义宏,定义成一个字符串  或者true

#define max(x,y) (x)>(y)?:(x),(y)   t应该这样#define ABS(x) ((x)>0? (x):-(x))         https://blog.csdn.net/hustli/article/category/12729     https://blog.csdn.net/benny5609/article/details/2314541

4. 回去搜腾讯课堂的服务器课程看看,一定得搜,看看异步IO什么的都是什么意思

5.#define DECLARE_MESSAGE(x) x();  class A{DECLARE_MESSAGE(A)};

6.cout和cerr的区别

 

首先通过一个例子就可以分析cout与cerr的区别,将下面代码编译链接后生成test.exe    

 

复制代码
1 #include   <iostream.h>
2     
3 int   main()
4 {
5      cout   <<   "hello   world---cout"   <<   endl   ;
6      cerr   <<   "hello   world---cerr"   <<   endl   ;
7      return   0;
8 }
复制代码

 

在命令行模式下键入下面的命令: test >>cout.txt

 

  运行结果是:   
在生成的cout.txt文件中输出了"hello world---cout"
同时在显示器上输出了"hello world---cerr"

 

MySql Connector/C++8简介

http://www.cnblogs.com/Focus-Flying/p/9316506.html

 

多线程问题博客:一定要看,而且windows核心编程也一定要看,太重要了!哎,没把握时间好好看,哎

https://blog.csdn.net/dazhong159/article/details/7927044 这是多线程6,再看看之前的5个,下面是转载参考的,也不错啊

https://blog.csdn.net/morewindows/article/details/7481609 非常好  https://blog.csdn.net/MoreWindows/article/details/7392749

https://blog.csdn.net/qq_24373811/article/details/52371120?locationNum=15

 

WaitForSingleObject的用法  https://www.cnblogs.com/killer-xc/p/6671318.html

了解下map和set的遍历操作,看看例子,需要学习的太多了,基础真的不行

posted @ 2018-09-30 10:21  努力专注C++  阅读(129)  评论(0编辑  收藏  举报