posts - 137,comments - 0,views - 40818

随笔分类 -  C++基础第一卷

上一页 1 2 3 4 5 下一页
C++ 友元函数/成员函数实现运算符重载
摘要:1.友元函数实现运算符重载(复数的加减法) Complex.h: #pragma once #include <string> using namespace std; class Complex { public: Complex(); Complex(int r, int i); void sh 阅读全文
posted @ 2022-11-30 21:28 wshidaboss 阅读(332) 评论(0) 推荐(0) 编辑
C++ 预防死锁和银行家算法(操作系统)
摘要:/*子函数声明*/ int Isprocessallover(); //判断系统中的进程是否全部运行完毕 void Systemstatus(); //显示当前系统中的资源及进程情况 int Banker(int, int*); //银行家算法 void Allow(int, int*); //若进 阅读全文
posted @ 2022-11-27 20:09 wshidaboss 阅读(289) 评论(0) 推荐(0) 编辑
C++ 随机读写:文件流的定位
摘要:1.seekg: 作用:设置输入流的位置 参数 1: 偏移量 参数 2: 相对位置 beg :相对于开始位置 cur: 相对于当前位置 end:相对于结束位置 #include <iostream> #include <string> #include <fstream> #include <sst 阅读全文
posted @ 2022-11-27 15:26 wshidaboss 阅读(112) 评论(0) 推荐(0) 编辑
C++ 使用文件流写/读文本文件、二进制文件、按指定格式写/读文本文件
摘要:1.使用文件流写文本文件: #include <iostream> #include <string> #include <fstream> using namespace std; int main() { string name; int age; ofstream offile;//文件输出流 阅读全文
posted @ 2022-11-26 19:21 wshidaboss 阅读(311) 评论(0) 推荐(0) 编辑
C++ 继承和派生的简单应用
摘要:Father.h: #pragma once #include <iostream> #include <string> using namespace std; class Father { public: Father(); Father(const string &name,int age); 阅读全文
posted @ 2022-11-20 20:58 wshidaboss 阅读(24) 评论(0) 推荐(0) 编辑
C++ 类的项目练习 定义一个类,来表示某模拟养成游戏中人物: 每个人物, 有昵称,年龄,性别, 配偶, 朋友, 支持的活动有:结婚,离婚, 交友,断交,询问昵称,询问性别,询问年龄, 简介等。
摘要:Hero.h: #pragma once #include <iostream> #include <string> #include <vector> #include <sstream> using namespace std; typedef enum gender { Man, //男 Wo 阅读全文
posted @ 2022-11-20 09:55 wshidaboss 阅读(36) 评论(0) 推荐(0) 编辑
C++ 类的简单应用 创建一个类,用来表示“玩具”,玩具有以下数据: 名称,价格,产地。 在使用中,需要获取它的名称, 价格, 产地。 注意:根据自己当前的优惠情况,有一个对外的价格。
摘要:Toy.h: #pragma once #include <iostream> #include <windows.h> #define DISCOUNT 5 //折扣,打5折 using namespace std; class Toy { public: Toy(); //构造函数 Toy(st 阅读全文
posted @ 2022-11-17 17:17 wshidaboss 阅读(67) 评论(0) 推荐(0) 编辑
C++ 很有意思的自动相亲交往系统基础版
摘要:Boy.h: #pragma once #include <string> #include <vector> using namespace std; class Girl; class Boy { public: Boy(); Boy(int age,string name,int salary 阅读全文
posted @ 2022-11-13 20:08 wshidaboss 阅读(39) 评论(0) 推荐(0) 编辑
C++中 vector容器的神奇用法
摘要:1.可以用简单的数据类型作为参数: #include <iostream> #include <vector> using namespace std; int main() { vector<int> data; data.push_back(1); data.push_back(5); for 阅读全文
posted @ 2022-11-13 17:08 wshidaboss 阅读(30) 评论(0) 推荐(0) 编辑
C语言实现羊了个羊小游戏的部分代码
摘要:#include <graphics.h> //easyx图形库的头文件 #include <stdio.h> #include <time.h> #define WIN_WIDTH 504 #define BLOCK_W 61 #define BLOCK_H 68 IMAGE imgBlocks[ 阅读全文
posted @ 2022-10-30 16:57 wshidaboss 阅读(728) 评论(0) 推荐(0) 编辑
C/C++ 交换机管理命令实战
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <conio.h> using namespace std; struct port { char name[16]; in 阅读全文
posted @ 2022-10-29 18:22 wshidaboss 阅读(131) 评论(0) 推荐(0) 编辑
C/C++ struct结构体的三种使用方法
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <conio.h> using namespace std; struct hero { char name[16]; ch 阅读全文
posted @ 2022-10-29 10:56 wshidaboss 阅读(142) 评论(0) 推荐(0) 编辑
C/C++ 一维数组和二维数组参数传递的几种方式
摘要:一维数组: #include <iostream> #include <windows.h> #include <string> using namespace std; //在以下几种方法中,ages都不是真正的数组,实际上是一个指针 int *ages int calAverage1(int a 阅读全文
posted @ 2022-10-23 15:06 wshidaboss 阅读(80) 评论(0) 推荐(0) 编辑
C++ 地震检测系统 (使用数据文件中的一组地震检波器测量值确定可能的地震事件的位置)
摘要:1.问题描述: 使用数据文件中的一组地震检波器测量值确定可能的地震事件的位置。 2.输入输出描述: (1)程序的输入是名为seismic.dat的数据文件和用于计算短时间能量和长时间能量的 取样值的数目。输出是给出关于潜在的地震事件次数的报告。 (2)seismic.dat 的结构是这样的,第一行包 阅读全文
posted @ 2022-10-17 20:55 wshidaboss 阅读(38) 评论(0) 推荐(0) 编辑
C/C++ 变量的四种存储类型以及它们的作用域和生存周期
摘要:所有的数据都有两种类型 数据类型: 如 int,float 等 存储类型: 总共有四种存储类型的变量,分别为自动变量(auto)、静态变量(static)、外部变量(extern)以及寄存器变量(register)。 (1)auto - 函数中所有的非静态局部变量。 (2)register - 一般 阅读全文
posted @ 2022-10-15 20:17 wshidaboss 阅读(190) 评论(0) 推荐(0) 编辑
C/C++ 为什么要使用动态内存?
摘要:为什么要使用动态内存? 1.按需分配,根据需要分配内存,不浪费; 2.被调用函数之外需要使用被调用函数内部的指针对应的地址空间; 3.突破栈区的限制,可以给程序分配更多的内存。 (1)C 内存分配: void *malloc(size_t size); void free(void *); mall 阅读全文
posted @ 2022-10-14 20:26 wshidaboss 阅读(183) 评论(0) 推荐(0) 编辑
C++程序的内存分区
摘要:1、栈区(stack):由编译器自动分配释放,存放函数的参数值,局部变量值等。 2、堆区(heap):一般由程序员分配释放,随叫随到,挥之即走。 3、全局/静态区(static):全局变量和静态变量的存储是放在一起的,在程序编译时分配。 4、文字常量区:存放常量字符串。 5、程序代码区:存放函数体( 阅读全文
posted @ 2022-10-14 16:54 wshidaboss 阅读(24) 评论(0) 推荐(0) 编辑
C++ 实现一个函数,使用指针连接两个字符串。 函数输入: 两个源字符串的指针,目的字符串的指针
摘要:#include <iostream> #include <string> #include <windows.h> using namespace std; bool str_cat(char* dest, int len, const char* st1, const char* st2) { 阅读全文
posted @ 2022-10-09 16:46 wshidaboss 阅读(222) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 下一页
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示