C++类的继承


#include <iostream>

class Box
{
public:
    // 构造函数
    Box(int h = 2, int w = 2, int len = 2);
    // 析构函数
    ~Box();
    int volume();

protected:
    int height, width, length;
};

Box::Box(int h, int w, int len)
{
    height = h;
    width = w;
    length = len;
}

Box::~Box()
{
    s...

Read more

C++类模板案例


#include <iostream>
#include <stdlib.h>

template <class T>

class Operation
{
private:
    T x, y;

public:
    Operation(T a, T b)
    {
        x = a;
        y = b;
    }
    T add();
    T sub();
};

template <class T>
T Operation<T>::add()
{
    return x + y;
}...

Read more

C语言字符串常用方法


// 字符长度
int strLenght(char *s) {
  int n = 0;
  while (*s != '\0') {
    n++;
    s++;
  }
  return n;
}

// 复制字符串 s2->s1
char *strCopy(char *s1, char *s2) {
  char *p = s1;
  while (*s2 != '\0') {
    *p = *s2;
    s2++;
    p++;
  }
  *p = '\0';
  return s1;
}

// 拼接字...

Read more

顺序队列的定义与方法


#include <stdio.h>
#include <stdlib.h>

#define MaxSize 100
#define bool char
#define True 1
#define False 0

typedef int ElemType;

typedef struct SeqQueue {
    ElemType data[MaxSize];
    int front, rear; // 队头、队尾指针
} SQ;


void initSeqQueue(SQ *sq) {
    sq->front = 0;
    sq-&...

Read more

顺序栈的定义与基础操作


#include <stdio.h>
#include <stdlib.h>

#define MaxSize 10
#define bool char
#define True 1
#define False 0

typedef int ElemType;

// 顺序栈类型定义
typedef struct stack {
    ElemType data[MaxSize];
    int top;
} SeqStack;


void init(SeqStack *s) {
    s->top = -1;
};

bool is_empty(S...

Read more

栈的链式存储结构及基本操作


#include <stdio.h>
#include <stdlib.h>

#define MaxSize 10
#define ElemType int
#define bool char
#define True 1
#define False 0

struct node {
    ElemType data;
    struct node *next;
};

struct node *top;

void init() {
    top = NULL;
}

bool is_empty() {
    if (top == NULL) {
  ...

Read more

Cmake基础用法


# CMakeLists.txt 文件常用配置
# cmake最小版本
cmake_minimum_required(VERSION 3.10)

# 项目名
project(demo1)

# 设置bin目录
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# 将源文件目录下所有源文件保存到SRC_LIST
aux_source_directory(src SRC_LIST)

# 指定头文件目录
include_directories(include)

# 将所有源文件编译成二进制程序
add_executable(d...

Read more

k8s基础


概述(官网)

Kubernetes 是一个可移植、可扩展的开源平台,用于管理容器化的工作负载和服务,可促进声明式配置和自动化。 Kubernetes 拥有一个庞大且快速增长的生态,其服务、支持和工具的使用范围相当广泛。

Kubernetes 这个名字源于希腊语,意为“舵手”或“飞行员”。k8s 这个缩写是因为 k 和 s 之间有八个字符的关系。 Google 在 2014 年开源了 Kubernetes 项目。 Kubernetes 建立在 Google 大规模运行生产工作负载十几年经验的基础上, 结合了社区中最优秀的想法和实践。

时光回溯

让我们回顾一下为何 Kubernetes 能够...

Read more