今日:0  |  文章:52
admin
小绿叶技术博客 Lv2 超级管理员

虚函数-纯虚函数与抽象类-待学习

C++ 中重要函数特性及相关机制的系统整理,涵盖面向对象、泛型编程、性能优化等核心场景: 一、面向对象核心机制(多态与继承) 1. 虚函数(Virtual Function) 定义:基类中用 virtual 声明的成员函数,允许派生类重写。 核心作用:实现运行时多态(动态绑定),通过基类指针 / 引用调用时,实际执行的是指向对象的类型对应的函数版本。 语法:virtual 返回类型 函数名(参数列表) { ... } 2. 函数重写(Override) 定义:派生类中定义与基类虚函数原型完全一致(返回值
/置顶
 173   2025-10-21
admin
小绿叶技术博客 Lv2 超级管理员

c 无限循环,限定次数判断达到次数 break 退出循环

#----- cs.c -----##include <stdio.h> void main(){ int ib=12; int cishu=0; for(;;) { ib--; cishu++; if(ib<1) { printf("\n [ok] 循环结束,当前 ib 值: %d \n",ib); break; }
/置顶
 1611   2023-04-19
admin
小绿叶技术博客 Lv2 超级管理员

c 语言 define ifdef endif c 宏的使用

#include<stdio.h> #define MAX #define MAXIMUM(x,y)(x>y)?x:y #define MINIMUM(x,y) (x>y)?y:x // 理解为: if ( x > y ) return y; else return x; // 符号() 判断 ; 问号 ? 条件成立(then) 返回y的值; 冒号 : 条件不成立(else)
/置顶
 2040   2023-03-09
admin
小绿叶技术博客 Lv2 超级管理员

c 控制led 灯逻辑代码

#include <stdio.h> #include <unistd.h> // sleep 函数包索引 int flag = 0; int flag1 =0; int cishu = 0; int jhcs = 3; // bool 是二进制类型; void test(int bit, int val) { // 由于 main 函数,我得到 数值: 1 1 printf("我是控制灯函数..."); // int const Mask = Bits
/置顶
 2014   2023-01-13
admin
小绿叶技术博客 Lv2 超级管理员

c++ 类

#include <iostream> #include <assert.h> using namespace std; // c++ 类 访问控制和继承,能访问的类型: // 同一个类: public protected [prəˈtektɪd] 受保护 private [ˈpraɪvət] 私有 // 派生类:public protected // 外部类:public class A{ public: // 定义类 A 的公共函数 A 和 fun int a
/置顶
 2136   2022-12-28
admin
小绿叶技术博客 Lv2 超级管理员

c 语言学习案例

nano eisc.c                                # 编辑c文件#include <stdio.h> // 函数外定义变量 x 和 yint x;int y;int addtwonum(){    // 函数内声明变量 x 和 y 为外部变量    e
/置顶
 1587   2022-05-07
admin
小绿叶技术博客 Lv2 超级管理员

内核调用iptables禁止ip访问-c++

// 内核调用iptables禁止ip访问 // 编写内核模块(最底层,效率最高) // 直接在内核态实现 IP 拦截逻辑,无需用户态程序介入,性能最优,但开发门槛高(需熟悉内核 API 和编译流程)。 // 核心思路: // 在内核中注册 netfilter 钩子函数(例如在 NF_INET_PRE_ROUTING 阶段,即数据包进入内核后优先处理)。 // 在钩子函数中检查数据包的源 IP 或目标 IP,若匹配黑名单则返回 NF_DROP。 // 简化示例(内核模块代码框架): // c // 运行
 
 172   2025-10-21
admin
小绿叶技术博客 Lv2 超级管理员

c++ 类函数编译错误问题

问题:.h 中定义类函数 class memSetClass { public: void writeToMemory 如果不满足下面条件会报错。 mem.cpp中定义需要将 .h 中的类 memSet跟上双冒号来定义类函数:void memSetClass::writeToMemory()-- Build files have been written to: /media/eisc/datadisk/eisc/www/gcc/build [ 25%] Building C
 
 661   2025-05-25
admin
小绿叶技术博客 Lv2 超级管理员

动态数组变量的写入读取修改-c++

#include <iostream> #include <vector> #include <string> #include <sstream> // 定义一个结构体来存储每行数据 struct Record { std::string ip; int value; std::string date; }; // 写入数据到内存 void writeToMemory(std::vector<Record>&
 
 832   2025-03-05
admin
小绿叶技术博客 Lv2 超级管理员

c 语言mqtt 连接脚本

#include <stdio.h> #include <stdlib.h> #include <string.h> #include "MQTTClient.h" #define MQTT_BROKER "mqtt.ddoss.cn" // MQTT代理服务器地址 #define MQTT_PORT 1883 // MQTT代理的默认端口,如果是TLS连接使用8883 #define MQTT_CLIENT_ID "CClient"
 
 884   2024-08-13
admin
小绿叶技术博客 Lv2 超级管理员

c语言 多个函数 作为数组,在mian 函数里 for 循环以此执行这三个函数 c/c++

#include<stdio.h> #include <time.h> void tione() { // 该程序要做的事情: // 1. ab和大于10,c=ab 否则 c=3a+2b // 2. a>b 则打印: 3(a+b) // 3. 排除 c大等于20 和 a>b 的情况,打印: 4c-5 // 4. a=a+b; b=a+b; c=a+b+c 打印各自的数字 int a=2,b=5,c; if(a+b>10){c=a*b;
 
 997   2024-06-21
admin
小绿叶技术博客 Lv2 超级管理员

linux debian12/ubuntu20/21/22安装 libpcap 网络抓包库

#!/bin/bash # debian12/ubuntu20/21/22 安装 网络抓包监控开发环境 libpcap downDir="/datadisk/eisc/download" ; installdir="/datadisk/eisc/server" ; debSystemList=( gcc flex byacc make cmake) ReleaseList=( libpcapRelease ) MysqlSelectVersion=0; debCheck() { for
 
 1572   2024-05-23
admin
小绿叶技术博客 Lv2 超级管理员

c++ 链表

#include <iostream> struct ListNode { // 链表通过节点实现,节点包含:数据和指向下一个节点的指针 int parameter; // 节点存储的数据 【属性1】 ListNode *next; // 链表桥接:链表类型被指针继承 【属性2】 ListNode(int x) : parameter(x), next(nul
 
 1368   2024-03-26
admin
小绿叶技术博客 Lv2 超级管理员

乒乓球比赛的记分表-统计乒乓球分数,含结构体的赋值与读取

#---- TableTennis.h ----#typedef struct { int aCount; int aStatusFlag; int aWinFourgamesFlag; int aCompetentFlag; }aScoreStruct; extern aScoreStruct aScoreS; typedef struct { int bCount; int bStatusFlag; int bWinFour
 
 1622   2024-03-13
admin
小绿叶技术博客 Lv2 超级管理员

memcpy c语言

uint8_t eisc66A[8], eisc666[8];memcpy(eisc66A,eisc666,8);// 将 eisc666 数组 赋值 给 eisc666  长度为 8 // 在赋值数组时候不用跟上数组长度,但是两个数组长度一致: 
 
 1637   2023-12-11
admin
小绿叶技术博客 Lv2 超级管理员

c 语言字符串批量生成

//---- gpio.h ----// #include <stdint.h> // uint 函数 头文件 static uint8_t ddrsum[6] = { 7, 3, 7, 3, 7, 7 }; // const 只读,不允许改变的关键字数组类型 /* static uint64_t gpioNM[] = { 'DDRT', 'DDRM', 'DDRS', 'DDRJ', 'DDRP', 'DDR0AD' }; */ static
 
 1817   2023-11-20
头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息