![](https://img-blog.csdnimg.cn/20190927151117521.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
c++基础入门
较重要的c++基础知识
NBattery
这个作者很懒,什么都没留下…
展开
-
deque和vector容器评委打分项目
#include<iostream>using namespace std;#include<vector>#include<algorithm>#include<string>#include<deque>#include<ctime>class Person {public: Person(string na, int s) :name(na), score(s) {} string n原创 2022-03-14 16:40:24 · 65 阅读 · 0 评论 -
vector存放自定义数据类型(类和指针)
#include<iostream>using namespace std;#include<vector>#include<string>class Person {public: Person(int age, string name) { this->age = age; this->name = name; } int age; string name; };void test01(){ vector<Per原创 2022-03-10 19:39:14 · 561 阅读 · 0 评论 -
关于vector容器的使用
在这里插入代码片#include<iostream>using namespace std;#include<vector>#include<algorithm>void myprint(int val){ cout << val << endl;}void test01(){ vector<int> v;//创建一个vector容器 v.push_back(10);//向容器中插入数据 v.push_back(原创 2022-03-10 19:16:32 · 78 阅读 · 0 评论 -
c++中友元的使用
全局函数做友元#include<iostream>using namespace std;class Person{ friend void guy(Person &p);//全局函数做友元可以访问私有内容 public: Person() { num = 23; age = 18; } int num; private: int age;};void guy(Person &p)//全局函数做友元{ cout <&.原创 2022-03-01 16:20:05 · 383 阅读 · 0 评论 -
const修饰成员函数以及常量指针和指针常量
#include<iostream>using namespace std;class Person{public: void fun() const //成员函数后加const为常函数 { this->a = 100;//加关键字mutable后,在常函数中依然可以修改 // this->b = 100; 常函数内不可修改成员属性 } void fun2() { b = 100; } int b; int mutable a;//加关键字mu原创 2022-03-01 15:05:38 · 80 阅读 · 0 评论 -
关于类中成员含有其他类时,构造函数和析构函数的执行顺序
#include<iostream>using namespace std;#include<string>class Phone{public: Phone(string phone) { phonename = phone; cout <<"释放" <<phonename << endl; } ~Phone() { cout << "释放手机" << endl; }private:原创 2022-02-27 23:28:14 · 585 阅读 · 0 评论 -
【黑马C++入门 通讯录管理系统】2022.2.26
#include <iostream>#include <string>using namespace std;struct Person{ string m_Name; //名字 string m_Sex; //性别 1男2女 int m_Age; //年龄 string m_Phone; //电话 string m_Addr; //住址};#define Max 1000 // 最大人数struct Addressbooks{ Person pers原创 2022-02-26 19:14:04 · 119 阅读 · 0 评论