【CPP】类和对象

1- Classes and Objects

Structures

  • A struct in C is a type consisting of a sequence of data members
  • Some functions/Statements are needed to operate the data members of an object of a struct type

在这里插入图片描述

不不小心操作错误,不小心越界

Classes

  • You should be very careful to manipulated the data members in a struct object
  • Can we improve struct to a better one ?
  • Yes, it is class ! We can put some member functions in it
class Student
{private:static size_t student_total; // declaration only//inline static size_t student_total = 0; //C++17, definition outside isn't neededchar * name;int born;bool male; void setName(const char * s){strncpy(name, s, sizeof(name));}
};
Student yu;
yu.setName("Yu");

firstclass.cpp

#include <iostream>
#include <cstring>class Student
{public:char name[4];int born;bool male; void setName(const char * s){strncpy(name, s, sizeof(name));}void setBorn(int b){born = b;}void setGender(bool isMale){male = isMale;}void printInfo(){std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;}
};int main()
{Student yu;yu.setName("Yu");yu.setBorn(2000);yu.setGender(true);yu.born = 2001; // it can also be manipulated directlyyu.printInfo();std::cout << "It's name is " << yu.name << std::endl; return 0;
}
Name: Yu
Born in 2001
Gender: Male
It's name is Yu

Access Specifiers

  • You can protect data members by access specifier private
  • Then data member can only be accessed by well designed member functions

access_attribute.cpp

#include <iostream>
#include <cstring>class Student
{private:char name[4];int born;bool male; public:void setName(const char * s){strncpy(name, s, sizeof(name));}void setBorn(int b){born = b;}void setGender(bool isMale){male = isMale;}void printInfo(){std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;}
};int main()
{Student yu;yu.setName("Yu");yu.setBorn(2000);yu.setGender(true);yu.born = 2001; // you cannot access a private memberyu.printInfo();return 0;
}
access-attribute.cpp:37:8: error: 'born' is a private member of 'Student'yu.born = 2001; // you cannot access a private member^
access-attribute.cpp:8:9: note: declared private hereint born;^

Member Functions

  • A member function can be defined inside or outside class
  • 如果在类内部实现函数则就是inline 函数

function.cpp

#include <iostream>
#include <cstring>class Student
{private:char name[4];int born;bool male; public:void setName(const char * s){strncpy(name, s, sizeof(name));}void setBorn(int b){born = b;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}int main()
{Student yu;yu.setName("Yu");yu.setBorn(2000);yu.setGender(true);yu.printInfo();return 0;
}
Name: Yu
Born in 2000
Gender: Male

File Structures

  • The source code can be placed into multiple files

student.hpp

#pragma once#include <cstring>
class Student
{private:char name[4];int born;bool male; public:void setName(const char * s){strncpy(name, s, sizeof(name));}void setBorn(int b){born = b;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};

student.cpp

#include <iostream>
#include "student.hpp"void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}

如果include <> 从编译器路径查找,如果是include "" 从编译器和当前目录找

main.cpp

#include "student.hpp"int main()
{Student yu;yu.setName("Yu");yu.setBorn(2000);yu.setGender(true);yu.printInfo();return 0;
}

CMakeList.txt

cmake_minimum_required(VERSION 3.12)project(persondemo)ADD_EXECUTABLE(persondemo main.cpp student.cpp)
cd multi-files
mkdir build
cd build
cmake ..
make
./persondemo
Name: Yu
Born in 2000
Gender: Male

2-Constructors and Destructors

Constructors

  • Different from struct in C, a constructor will be invoked when creating an object of a class

(1) struct in C: allocate memory
(2) class in C++: allocate memory & invoke a constructor

  • But, No constructor is defined explicitly in previous examples

(1) the compiler wil generate one with empty body

如果没有人为定义构造函数,则自动会有一个空的构造函数

  • The same name with the class
  • Have no return value

class Student
{private:char name[4];int born;bool male; public:Student(){name[0] = 0;born = 0;male = false;cout << "Constructor: Person()" << endl;}}Student(const char * initName, int initBorn, bool isMale){setName(initName);born = initBorn;male = isMale;cout << "Constructor: Person(const char, int , bool)" << endl;}
}
  • The members can also be initialized as follows
    Student(const char * initName): born(0), male(true){setName(initName);cout << "Constructor: Person(const char*)" << endl;}

把成员变量born 初始化为0 , 把male 初始化为true

constructor.cpp

#include <iostream>
#include <cstring>using namespace std;class Student
{private:char name[4];int born;bool male; public:Student(){name[0] = 0;born = 0;male = false;cout << "Constructor: Person()" << endl;}Student(const char * initName): born(0), male(true){setName(initName);cout << "Constructor: Person(const char*)" << endl;}Student(const char * initName, int initBorn, bool isMale){setName(initName);born = initBorn;male = isMale;cout << "Constructor: Person(const char, int , bool)" << endl;}void setName(const char * s){strncpy(name, s, sizeof(name));}void setBorn(int b){born = b;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}int main()
{Student yu;yu.printInfo();yu.setName("Yu");yu.setBorn(2000);yu.setGender(true);yu.printInfo();Student li("li");li.printInfo();Student xue = Student("XueQikun", 1962, true);//a question: what will happen since "XueQikun" has 4+ characters?xue.printInfo();Student * zhou =  new Student("Zhou", 1991, false);zhou->printInfo();delete zhou;return 0;
}
Constructor: Person()
Name: 
Born in 0
Gender: Female
Name: Yu
Born in 2000
Gender: Male
Constructor: Person(const char*)
Name: li
Born in 0
Gender: Male
Constructor: Person(const char, int , bool)
Name: XueQ�
Born in 1962
Gender: Male
Constructor: Person(const char, int , bool)
Name: Zhou�
Born in 1991
Gender: Female

Destructors

  • The destructor will be invoked when the object is destroyed
  • Be formed from the class name preceded by a tilde(~)
  • Have no return value, no parameters
    ~Student(){cout << "To destroy object: " << name << endl;delete [] name;}

析构函数只能有一个
析构函数常做的事情:释放内存,关闭文件,断掉网络etc

destructor.cpp

#include <iostream>
#include <cstring>using namespace std;class Student
{private:char * name;int born;bool male; public:Student(){name = new char[1024]{0};born = 0;male = false;cout << "Constructor: Person()" << endl;}Student(const char * initName, int initBorn, bool isMale){name =  new char[1024];setName(initName);born = initBorn;male = isMale;cout << "Constructor: Person(const char, int , bool)" << endl;}~Student(){cout << "To destroy object: " << name << endl;delete [] name;}void setName(const char * s){strncpy(name, s, 1024);}void setBorn(int b){born = b;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}int main()
{{Student yu;yu.printInfo();yu.setName("Yu");yu.setBorn(2000);yu.setGender(true);yu.printInfo();}Student xue = Student("XueQikun", 1962, true);xue.printInfo();Student * zhou =  new Student("Zhou", 1991, false);zhou->printInfo();delete zhou;return 0;
}
g++ destructor.cpp --std=c++11
Constructor: Person()
Name: 
Born in 0
Gender: Female
Name: Yu
Born in 2000
Gender: Male
To destroy object: Yu
Constructor: Person(const char, int , bool)
Name: XueQikun
Born in 1962
Gender: Male
Constructor: Person(const char, int , bool)
Name: Zhou
Born in 1991
Gender: Female
To destroy object: Zhou
To destroy object: XueQikun

人工手动调用析构函数 delete zhou,作用域结束跳出也会自动调用析构函数
如果对于new 的对象不进行手动删除delete 则作用域结束也不会动态调用析构函数,造成内存泄漏

    Student * class1 = new Student[3]{{"Tom", 2000, true},{"Bob", 2001, true},{"Amy", 2002, false},};
  • What is the different between the following two lines?
delete class1;
delete [] class1;

array.cpp

#include <iostream>
#include <cstring>using namespace std;class Student
{private:char * name;int born;bool male; public:Student(){name = new char[1024]{0};born = 0;male = false;cout << "Constructor: Person()" << endl;}Student(const char * initName, int initBorn, bool isMale){name =  new char[1024];setName(initName);born = initBorn;male = isMale;cout << "Constructor: Person(const char, int , bool)" << endl;}~Student(){cout << "To destroy object: " << name << endl;delete [] name;}void setName(const char * s){strncpy(name, s, 1024);}void setBorn(int b){born = b;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}int main()
{Student * class1 = new Student[3]{{"Tom", 2000, true},{"Bob", 2001, true},{"Amy", 2002, false},};class1[1].printInfo();delete class1;delete []class1;return 0;
}
Constructor: Person(const char, int , bool)
Constructor: Person(const char, int , bool)
Constructor: Person(const char, int , bool)
Name: Bob
Born in 2001
Gender: Male
To destroy object: Tom

数组调用析构函数delete class1 , 只会调用第一个对象的析构函数,后面的对象不会被调用

数组调用析构函数 delete [] class1,则会调用全部对象的析构函数

Constructor: Person(const char, int , bool)
Constructor: Person(const char, int , bool)
Constructor: Person(const char, int , bool)
Name: Bob
Born in 2001
Gender: Male
To destroy object: Amy
To destroy object: Bob
To destroy object: Tom

3-this pointer

Why is this needed

  • How does a member function know which name?

在这里插入图片描述

this Pointer

  • All methods in a function have a this pointer
  • It is set to the address of the object that invokes the method

在这里插入图片描述

this.cpp

#include <iostream>
#include <cstring>using namespace std;class Student
{private:char * name;int born;bool male; public:Student(){name = new char[1024]{0};born = 0;male = false;cout << "Constructor: Person()" << endl;}Student(const char * name, int born, bool male){this->name =  new char[1024];this->setName(name);this->born = born;this->male = male;cout << "Constructor: Person(const char, int , bool)" << endl;}~Student(){cout << "To destroy object: " << name << endl;delete [] name;}void setName(const char * name){strncpy(this->name, name, 1024);}void setBorn(int born){this->born = born;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}int main()
{Student * class1 = new Student[3]{{"Tom", 2000, true},{"Bob", 2001, true},{"Amy", 2002, false},};class1[1].printInfo();delete []class1;return 0;
}
Constructor: Person(const char, int , bool)
Constructor: Person(const char, int , bool)
Constructor: Person(const char, int , bool)
Name: Bob
Born in 2001
Gender: Male
To destroy object: Amy
To destroy object: Bob
To destroy object: Tom

4- const and static Members

const Variables

  • statements for constants

在这里插入图片描述

C++不推荐用 宏

const Members

  • const member variables behavior similar with normal const variables
  • const member functions promise not to modify member variables
class Student
{private:const int BMI = 24;public:Student(){BMI = 25;//can it be modified?int getBorn() const{born++; //Can it be modified?return born;}
};

常量函数,const 放在后面,不然跟前面的const int相冲突。不可以修改成员变量,born 是不可以被修改的,保证不修改函数里的变量

const.cpp

#include <iostream>
#include <cstring>using namespace std;class Student
{private:const int BMI = 24;char * name;int born;bool male; public:Student(){name = new char[1024]{0};born = 0;male = false;// BMI = 25;//can it be modified?cout << "Constructor: Person()" << endl;}Student(const char * name, int born, bool male){this->name =  new char[1024];setName(name);this->born = born;this->male = male;cout << "Constructor: Person(const char, int , bool)" << endl;}~Student(){cout << "To destroy object: " << name << endl;delete [] name;}void setName(const char * name){strncpy(this->name, name, 1024);}void setBorn(int born){this->born = born;}int getBorn() const{//born++; //Can it be modified?return born;}// the declarations, the definitions are out of the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}int main()
{Student yu("Yu", 2000, true);cout << "yu.getBorn() = " << yu.getBorn() << endl;return 0;
}
Constructor: Person(const char, int , bool)
yu.getBorn() = 2000
To destroy object: Yu

static members

  • static members are not bound to class instances
class Student
{private:static size_t student_total; // declaration onlypublic:Student(){student_total++;}~Student(){student_total--;}static size_t getTotal() {return student_total;}
};// definition it here
size_t Student::student_total = 0; 

静态成员不绑定在类对象上,只有一个

static.cpp

#include <iostream>
#include <cstring>using namespace std;class Student
{private:static size_t student_total; // declaration only//inline static size_t student_total = 0; //C++17, definition outside isn't neededchar * name;int born;bool male; public:Student(){student_total++;name = new char[1024]{0};born = 0;male = false;cout << "Constructor: Person(): student_total = " << student_total << endl;}Student(const char * initName, int initBorn, bool isMale){student_total++;name =  new char[1024];setName(initName);born = initBorn;male = isMale;cout << "Constructor: Person(const char, int , bool): student_total = " << student_total << endl;}~Student(){student_total--;cout << "To destroy object: " << name ;cout << ". Then " << student_total << " students are left" << endl;delete [] name;}void setName(const char * s){strncpy(name, s, 1024);}void setBorn(int b){born = b;}static size_t getTotal() {return student_total;}// the declarations, the definitions are out sof the classvoid setGender(bool isMale);void printInfo();
};void Student::setGender(bool isMale)
{male = isMale;
}
void Student::printInfo()
{std::cout << "Name: " << name << std::endl;std::cout << "Born in " << born << std::endl;std::cout << "Gender: " << (male ? "Male" : "Female") << std::endl;
}size_t Student::student_total = 0; // definition it hereint main()
{cout << "---We have " << Student::getTotal() << " students---" << endl;Student * class1 = new Student[3]{{"Tom", 2000, true},{"Bob", 2001, true},{"Amy", 2002, false},};cout << "---We have " << Student::getTotal() << " students---" << endl;Student yu("Yu", 2000, true);cout << "---We have " << Student::getTotal() << " students---" << endl;class1[1].printInfo();delete []class1;cout << "---We have " << Student::getTotal() << " students---" << endl;return 0;
}
---We have 0 students---
Constructor: Person(const char, int , bool): student_total = 1
Constructor: Person(const char, int , bool): student_total = 2
Constructor: Person(const char, int , bool): student_total = 3
---We have 3 students---
Constructor: Person(const char, int , bool): student_total = 4
---We have 4 students---
Name: Bob
Born in 2001
Gender: Male
To destroy object: Amy. Then 3 students are left
To destroy object: Bob. Then 2 students are left
To destroy object: Tom. Then 1 students are left
---We have 1 students---
To destroy object: Yu. Then 0 students are left

静态函数里面不可以修改非静态数据

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/123799.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++设计模式_18_State 状态模式

State和Memento被归为“状态变化”模式。 文章目录 1. “状态变化”模式1.1 典型模式 2. 动机 (Motivation)3. 代码演示State 状态模式3.1 常规方式3.2 State 状态模式 4. 模式定义5. 结构( Structure )6. 要点总结7. 其他参考 1. “状态变化”模式 在组件构建过程中&#xf…

Ionic 7 版本发布 - 免费开源、超受欢迎的移动应用开发 UI 工具包,主题优雅且完美支持 Vue.js

Ionic 是一款优秀的移动 UI 框架&#xff0c;迭代也很快&#xff0c;现在也支持了 Vue&#xff0c;是时候向大家推荐用来开发 APP 了。 Ionic 全称是 Ionic Framework&#xff0c;是一个功能强大的开源 UI 工具库&#xff0c;用来帮助前端开发者构建跨平台的移动应用。 Ionic …

rhcsa目录练习

要求 在根下创建一个叫做test的目录&#xff0c;在test的目录下创建三个普通文件file1 file2 file3&#xff0c;给file1创建一个软链接aa&#xff0c;给file2创建两个硬链接&#xff0c;在test目录下创建一个ceshi的目录&#xff0c;在ceshi的目录下创建a1-a8,b1-b8,ac1-ad8的…

【前端框架】本文带你了解nvue

前言 各位公主给&#x1f478;&#x1f3fb;&#xff0c;王子&#x1f934;&#x1f3fb;好&#xff0c;我是你们的Aic山鱼&#xff0c;专注于前端领域的垂直更新。我热衷于分享我的经验和知识&#xff0c;希望能够帮助更多的人在前端领域取得进步。作为一名前端开发人员&#…

Linux 系统调用IO口,利用光标偏移实现文件复制

用系统调用IO函数实现从一个文件读取最后2KB数据并复制到另一个文件中&#xff0c;源文件以只读方式打开&#xff0c;目标文件以只写的方式打开&#xff0c;若目标文件不存在&#xff0c;可以创建并设置初始值为0664&#xff0c;写出相应代码&#xff0c;要对出错情况有一定的处…

【C++】搜索二叉树

提示&#xff1a;写完文章后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 一、搜索二叉树概念二、搜索二叉树的操作1.插入2. 查找3. 中序遍历4. 删除 三、默认成员函数1.析构函数2.拷贝构造3. 赋值运算符重载 四、完整代码 一、搜索二叉树概…

SSM宾馆客房管理系统开发mysql数据库web结构java编程计算机网页源码eclipse项目

一、源码特点 SSM 宾馆客房管理系统是一套完善的信息系统&#xff0c;结合springboot框架和bootstrap完成本系统&#xff0c;对理解JSP java编程开发语言有帮助系统采用SSM框架&#xff08;MVC模式开发&#xff09;&#xff0c;系统具有完整的源代 码和数据库&#xff0c;系统…

任正非说:扩张必须踩在坚实的基础上,擅自扩张只能是自杀。

嗨&#xff0c;你好&#xff01;这是华研荟【任正非说】系列的第23篇文章&#xff0c;让我们继续聆听任正非先生的真知灼见&#xff0c;学习华为的管理思想和管理理念。 一、要想赢&#xff0c;要么在剑法上高于人&#xff0c;要么在盾牌上坚于人。若果剑不如人&#xff0c;就要…

大厂面试题-JVM为什么使用元空间替换了永久代?

目录 面试解析 问题答案 面试解析 我们都知道Java8以及以后的版本中&#xff0c;JVM运行时数据区的结构都在慢慢调整和优化。但实际上这些变化&#xff0c;对于业务开发的小伙伴来说&#xff0c;没有任何影响。 因此我可以说&#xff0c;99%的人都回答不出这个问题。 但是…

一文读懂:到底什么是Chiplets?

50多年来&#xff0c;Intel和AMD一直是两家主流的处理器公司。 虽然两者都使用x86 ISA来设计新品&#xff0c;但是在过去十多年左右的时间里&#xff0c;两家cpu公司却走上了完全不同的道路。 大约在2000年代中期&#xff0c;随着推土机(Bulldozer)芯片推出&#xff0c;AMD在…

Flask基本教程以及Jinjia2模板引擎简介

flask基本使用 直接看代码吧&#xff0c;非常容易上手&#xff1a; # 创建flask应用 app Flask(__name__)# 路由 app.route("/index", methods[GET]) def index():return "FLASK&#xff1a;欢迎访问主页&#xff01;"if __name__ "__main__"…

OpenCV学习笔记

OpenCV基础 threshold函数的使用 https://blog.csdn.net/u012566751/article/details/77046445 图像的二值化就是将图像上的像素点的灰度值设置为0或255&#xff0c;这样将使整个图像呈现出明显的黑白效果。在数字图像处理中&#xff0c;二值图像占有非常重要的地位&#xff0…

线扫相机DALSA--常见问题一:软件安装顺序

1.软件安装顺序 先安装&#xff1a;Sapera_LT_SDK&#xff0c;后安装Xtium-CL MX4驱动。 2.初次安装CamExpert&#xff0c;重启电脑后未找到相机 Settings(搜索协议)配置完毕后&#xff0c;需点击Detect Camera(一键查找相机)按钮&#xff0c;搜索相机。第一次查找相机耗时会略…

聚观早报 |蔚来推出婚车服务;长城汽车第三季度财报

【聚观365】10月30日消息 蔚来推出婚车服务 长城汽车第三季度财报 AI汽车机器人极越01上市 谷歌投资初创公司Anthropic 东方财富第三季度营收 蔚来推出婚车服务 据蔚来汽车官方消息&#xff0c;蔚来宣布推出“蔚来用户专享”的婚庆用车定制服务。 据悉&#xff0c;该服务…

Mac删除照片快捷键ctrl加什么 Mac电脑如何批量删除照片

Mac电脑是很多人喜欢使用的电脑&#xff0c;它有着优美的设计、高效的性能和丰富的功能。如果你的Mac电脑上存储了很多不需要的照片&#xff0c;那么你可能会想要删除它们&#xff0c;以节省空间和提高速度。那么&#xff0c;Mac删除照片快捷键ctrl加什么呢&#xff1f;Mac电脑…

微信小程序实现微信登录(Java后台)

这两天在自己的小项目中加入了微信小程序的很多功能&#xff0c;今天来说一下关于微信授权登录的部分。 需要的材料 1&#xff1a;一个可以测试的微信小程序 2&#xff1a;此微信小程序的APPID和APPscret 流程 微信用户对应一个小程序都有一个唯一的openid&#xff0c;微信…

【文末送书】AI时代数据的重要性

欢迎关注博主 Mindtechnist 或加入【智能科技社区】一起学习和分享Linux、C、C、Python、Matlab&#xff0c;机器人运动控制、多机器人协作&#xff0c;智能优化算法&#xff0c;滤波估计、多传感器信息融合&#xff0c;机器学习&#xff0c;人工智能等相关领域的知识和技术。关…

分享个自己写的小程序解包工具

闲聊 前几天在吾爱破解上看到一个小程序逆向的帖子&#xff1a;windows下通杀wx小程序云函数实战 &#xff0c;想着自己也学习一下怎么逆向小程序&#xff0c;一搜 unveilr 仓库没了&#xff0c;看评论好像开始收费了。 我就用aardio写了一个解密和解包工具&#xff0c;这里免…

Kotlin协程核心理解

一、协程是什么&#xff1f; 1.1 基本概念的理解 我们知道JVM中的线程的实现是依赖其运行的操作系统决定的&#xff0c;JVM只是在上层进行了API的封装&#xff0c;包含常见的有线程的启动方法&#xff0c;状态的管理&#xff0c;比如&#xff1a;Java中抽象出了6种状态&#x…

深入理解指针3

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 目录 前言 1. 字符指针变量 2. 数组指针变量 2.1 数组指针变量是什么&#xff1f; 2.2 数组指针变量怎么初始化 3. 二维数组传参的本质 4. 函数指针变量 4.1 函数指针变量的创…