摘要:1 #include <cstddef> 2 #include <cstdlib> 3 #include <iostream> 4 #include "string.h" 5 using namespace std; 6 7 8 void GetMemory(char **p,int num) 9 阅读全文
指针运算
2022-11-15 22:27 by 钟铧若岩, 23 阅读, 0 推荐, 收藏,
摘要:1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int a =100; 6 int *b = &a; 7 char *c; 8 char *d = "hello world"; 9 c = d; 10 cout << " 阅读全文
批针与引用的区别
2022-11-15 21:42 by 钟铧若岩, 40 阅读, 0 推荐, 收藏,
摘要:1)非空区别 在任何情况下都不能使用指向空值的引用,一个引用必须总是指向某些对象 2)合法性区别 在使用引用之前不需要测试它的合法性,相反,指针则应总被测试,防止其为空。 3)可修改区别 指针可以被重新赋值以指向另一个不同的对象,但是引用则总是指向在初始化时被指定的对象 4)应用区别 指针可指向空, 阅读全文
空类与多重继承占用空间大小
2022-11-15 21:31 by 钟铧若岩, 16 阅读, 0 推荐, 收藏,
摘要:虚继承涉及虚表(虚指针),所以sizeof(C) = 8 1 #include <iostream> 2 using namespace std; 3 4 class A{}; 5 class A2{}; 6 class B:public A 7 {}; 8 9 class C:public vir 阅读全文
Class,strict sizeof用法
2022-11-13 15:26 by 钟铧若岩, 30 阅读, 0 推荐, 收藏,
摘要:1 #include "iostream" 2 using namespace std; 3 4 class A{}; 5 class A2{char d,e;}; 6 struct B{}; 7 struct C{char b,c;}; 8 struct D{int x,y;}; 9 10 int 阅读全文
Size of的用法
2022-11-13 15:10 by 钟铧若岩, 90 阅读, 0 推荐, 收藏,
摘要:1 #include <cstdlib> 2 #include <iostream> 3 #include <iterator> 4 #include "string.h" 5 using namespace std; 6 struct{ 7 short a1; 8 short a2; 9 shor 阅读全文
const的作用
2022-11-13 12:04 by 钟铧若岩, 87 阅读, 0 推荐, 收藏,
摘要:1)定义const常量 2)const可以修饰函数的参数和返回值, 甚至函数定义体,被const修饰的东西都受到强制保护,可以预防意外的变动,能提高程序的健壮性 阅读全文
指针常量、常量指针
2022-11-13 11:58 by 钟铧若岩, 47 阅读, 0 推荐, 收藏,
摘要:1 #include <stdio.h> 2 #include <string.h> 3 4 int main(int argc, char **argv) { 5 printf("Hello, World!\n"); 6 7 int a = 10; 8 int a1 = 20; 9 //不能再修改 阅读全文
字符串函数以及宏定义
2022-11-13 11:41 by 钟铧若岩, 57 阅读, 0 推荐, 收藏,
摘要:最小值、以及平方的宏定义实现,注意()的使用 1 #include <stdio.h> 2 #include <string.h> 3 4 #define MIN(a,b) (a)<(b)?(a):(b) 5 #define SQRT(a) (a)*(a) 6 7 int main(int argc 阅读全文
在main函数执行完后,再执行其他方法
2022-11-13 11:24 by 钟铧若岩, 53 阅读, 0 推荐, 收藏,
摘要:方法如下: 1 #include <stdio.h> 2 3 int atexit(void(*function)(void)); 4 void fn1(void), fn2(void); 5 6 int main(int argc, char **argv) { 7 printf("Hello, 阅读全文
浙公网安备 33010602011771号