![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
easy_coder
这个作者很懒,什么都没留下…
展开
-
makefile脚本语言
语法一、显示规则1)目标文件:依赖文件[TAB]指令([TAB]是键位)2)第一个目标文件是我们的最终目标3)#是注释4)伪目标伪目标:.PHONY:#第一个目标文件是最终目标!!!像递归hello:hello.o gcc hello.o -o hellohello.o:hello.s gcc -c hello.s -o hello.ohello.s:hello.i gcc -S hello.i -o hello.shello.i:hello.c gcc -E原创 2020-12-16 17:10:52 · 354 阅读 · 1 评论 -
C/C++编译执行过程
微观的C/C++执行过程C语言 .c ----> .exe过程:1)预处理把.h .c文件展开形成一个文件。宏定义直接替换、头文件库文件直接打开。生成.i文件预处理指令 -E2)汇编.i文件生成汇编代码文件.s汇编指令 -S3)编译.s文件编译成目标代码文件.o编译指令 -c4)链接.o 链接 .exe(windows) .elf(linux)预处理 gcc -E hello.c -o hello.i汇编 gcc -S hello.i -o hello.s编译原创 2020-12-16 11:31:24 · 170 阅读 · 0 评论 -
可变参数的宏
举例#define LOG(format, …) do { char msg[128];sprintf(msg, format, VA_ARGS);fprintf(stdout, “%s\n”, msg);}while(0)其中,…表示参数可变,__VA_ARGS__在预处理中为实际的参数集所替换在上述定义的宏不能省略可变参数。如果要省略需要在__VA_ARGS__前加###include <stdio.h>#include <stdarg.h>#define原创 2020-12-09 16:28:47 · 126 阅读 · 0 评论 -
printf、sprintf、fprintf区别
区别都是把格式好的字符串输出,但是输出的目标不一样printf格式:int pintf(const char * format,…)把格式字符串输出到标准输出(一般是屏幕)#include <stdio.h>int main() { printf("hello world\n"); return 0;}sprintf格式:int sprintf(chat* str, const char * format,…)把格式字符串输出到指定字符串中,即st原创 2020-12-09 15:58:28 · 139 阅读 · 0 评论 -
C++ static关键字作用
C++中static作用总结1、隐藏功能(C/C++)2、静态局部变量(C/C++)3、类成员声明为static(C++)隐藏功能当全局变量和函数声明为static,只能在本文件中可见,对于其他文件不可见。其他文件可以有相同的函数/变量名字,不会冲突。// test.cpp#include <iostream>using namespace std;int n = 10; int add(int a, int b) { return a + b;} int原创 2020-12-09 14:32:40 · 137 阅读 · 0 评论 -
虚函数与纯虚函数
虚函数与纯虚函数的区别虚函数的作用虚函数的作用基类的指针可以调用子类的该函数,虚函数在基类中必须要实现。纯虚函数在基类中不需要实现,子类中必须实现该函数。虚函数#include <iostrem>using namespace std;class Animal {public: virtual void printClassName() { cout << "Animal" << endl; } };class原创 2020-12-08 11:16:42 · 324 阅读 · 0 评论 -
C++
*与++优先级问题前缀递增递减与*的优先级相同,从右向左后缀递增递减的优先级比*的优先级低,从左到右*p++:先执行*p,p再增1*++p:p先增1,再执行*p举例: char arr[] = "abcdefghi"; char* p = arr;*p++:先*p值为a,再p++*++p:p先增1,再执行*p,值为b完整代码:#include <iostream>using namespace std;int main(int argc, const cha原创 2020-09-01 15:23:16 · 108 阅读 · 0 评论