cpp all记录


1、BOOL AddLocalIPToList(std::vector& a, std::vector& b);

如果不用引用,则a ,b的值没法返回,要 再queding to thi

2、

    char ch;
    ch = getchar();
    switch(ch){
        case 'X': cout<<'X'<<endl;
        case 'Y': cout<<'Y'<<endl;
        default: cout<<'Z'<<endl;
    }
    

switch要重新结to thi, case 只选择起始点但不自动中断 所以后面要有break

3、

#pragma pack(1)
struct test{
    char x[5];
    char z[5];
    long long y;
};
printf("%d --\n", sizeof(struct test));

结果 20

字节对齐,pragma pack(X),大于x的成员要重新排,不大于的连续排即可

4、指针常量 常量指针

指针常量 : int * const p;

常量指针:int const *p;  或者const int *p;

记忆 const修饰左边的,左边没有修饰最近的。

5、

#include "stdafx.h"

#include "../new_stdafx.h"
#include "ui_menu.h"

因为ui_menu.h 里用到了"../new_stdafx.h"头文件里的内容,所以两个头文件顺序翻一下就不行了

相关