2021年4月22日

摘要: extern C浅析 //c++中想调用c语言函数 xxx.h #pragma once #ifdef __cplusplus //两个_下划线 extern "C" { #endif // !__cplusplus //两个_下划线 #include <stdio.h> void show(); 阅读全文
posted @ 2021-04-22 10:45 lodger47 阅读(39) 评论(0) 推荐(0)
摘要: 函数的默认参数 //注意事项:入股哦有一个位置有了默认参数,那么从这个位置开始,从左往后都必须有默认参数 //函数声明和实现里,只能有一个里面有默认参数,不能同时都有默认参数 void test03(int a = 20, int b = 30) {cout << "a + b = " << a + 阅读全文
posted @ 2021-04-22 10:15 lodger47 阅读(51) 评论(0) 推荐(0)
摘要: c++ (宏函数和内联函数) #define MyAdd(x,y) (x+y) //宏函数 void test(){ MyAdd(10,10)*xxx;//调用宏函数 } //内联函数用来代替宏 inline void mycompare(int a, int b) { int ret = a < 阅读全文
posted @ 2021-04-22 10:01 lodger47 阅读(141) 评论(0) 推荐(0)

2021年4月21日

摘要: c++(常量的引用) #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; void test01() { //int &ref=10; //引用了不合法的内存,不可以 const int &ref = 10 阅读全文
posted @ 2021-04-21 19:06 lodger47 阅读(52) 评论(0) 推荐(0)
摘要: struct Person { int m_Age; }; void allocatMemory(Person **p) //**p具体person本体 *p对象的指针 p指针的指针 { *p = (Person *)malloc(sizeof(Person)); (*p)->m_Age = 200 阅读全文
posted @ 2021-04-21 19:00 lodger47 阅读(42) 评论(0) 推荐(0)
摘要: namespace KingGlory { int sunwukongID = 10; } void test01() { int sunwukongID = 20; //using KingGlory::sunwukongID;//也会有二义性 cout << sunwukongID << end 阅读全文
posted @ 2021-04-21 18:00 lodger47 阅读(31) 评论(0) 推荐(0)
摘要: 双冒号 int val = 200; void test_one() { int val = 400; //双冒号为全局作用域的变量 cout << val << ::val << endl; } 用途 解决名称冲突问题 必须在全局作用域下 xxx.h #include <iostream> usi 阅读全文
posted @ 2021-04-21 17:49 lodger47 阅读(77) 评论(0) 推荐(0)
摘要: C++Primer(Sales_item类) #ifndef SALESITEM_H #define SALESITEM_H #include <iostream> #include <string> class Sales_item { public: Sales_item(const std:: 阅读全文
posted @ 2021-04-21 13:18 lodger47 阅读(154) 评论(0) 推荐(0)

2021年4月20日

摘要: 常量的定义 const 数据类型 常量名 #define 常量名 值 注意: 1.通过#define定义的常量是根据值来匹配数据类型的 2.const修饰的常量是不安全的可以通过指针来修改(只是针对c语言,c++是安全的) 阅读全文
posted @ 2021-04-20 15:26 lodger47 阅读(1119) 评论(0) 推荐(0)
摘要: centos7 这里面保存了创建新用户的系统配置文件:cd /etc/skel/ 阅读全文
posted @ 2021-04-20 14:11 lodger47 阅读(150) 评论(0) 推荐(0)

导航