自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 杭电计算机网络实验二~十六 合集 (含github仓库链接)

本人的杭电计算机网络实验报告 合集

2021-12-13 23:17:14 5742

原创 Sublime Text Python交互环境配置(调用终端) MAC版本(不使用sublimeREPL)

在csdn上看了很多博客,对于mac上python交互环境的配置,许多人都推荐用sublimeREPL这个插件,在运行python文件的时候在当前界面新弹出一个窗口来进行python指令交互,体验不是很好。我在youtube上看到国外一个大大开发了Terminus插件和origami这两个插件,并做了一个利用这两个插件配置python交互环境的视频。以下这篇文章总结了视频里的教程。本篇博客内容基于https://www.youtube.com/watch?v=mV0ghkMwTQc&t=208

2020-07-29 14:41:44 1772 22

原创 C++ 操作符重载与返回引用

今天在写C++作业的时候碰到这么个问题:如果函数返回的是引用,则不能返回局部变量。c++中临时变量不能作为非const的引用参数。看这段代码:#include <iostream>using namespace std;class CYls{public: CYls(int zi = 0, int mu = 0){this->zi = zi; this->...

2020-04-12 20:06:17 562

原创 multidimensional arrays in C++

Supposed that we need to collect test mark of a numebr of students, then we can use multidimensional arrays to handle it.Say that each students have four test marks, and there are 4 students in all....

2020-03-22 11:27:56 209

原创 C++ 中const 关键字

为了共享数据并且防止数据被篡改,C++中引入了const关键词,应用于长对象、常成员、常引用等方面。在写常成员函数的时候,函数相同,但是加了const和不加const关键词是会是两个不一样的函数://常成员函数#include <iostream>using namespace std;class R{public: R(int r1, int r2) : r1(r...

2020-03-15 15:31:14 113

原创 C++ 友元类

可以声明B类是A类的友元,这样B的函数就可以访问A的数据(公有私有都行),但是友元关系是单向的,也就是说,A的函数不能访问B的数据。//友元类#include <iostream>using namespace std;class A{ friend class B; //注意写法public: void display(){cout << x <&...

2020-03-15 14:58:01 128

原创 C++ 类中的静态数据成员和静态函数成员

在C++中,若类中的数据成员是静态数据成员,则必须在类外进行初始化和定义,并且需要用 :: 来指明其所属的类.用static声明该数据成员#include <iostream>using namespace std;class Point{public: Point(int x = 0,int y = 0) //构造函数 : x(x),y(y){ count++; ...

2020-03-15 14:30:45 297

原创 C ++ 函数中的静态变量

在函数中的静态变量,只在进入函数的第一次进行初始化,而动态变量,在每次进入函数的时候,都会被初始化。//变量的生存期与可见性#include <iostream>using namespace std;int i = 1; //全局变量void other(){ static int a = 2; static int b; //a、b为静态局部变量,局部可见 有全局...

2020-03-15 14:25:47 1937

原创 C++ 作用域

全局变量和局部变量的区别即使变量名是同一个,在全局和局部,两者的数值可能是不同的#include <iostream>using namespace std;int i; //这里的是全局变量int main(){ i = 5; //这里为全局变量赋值 { //一个新的子块 int i; //这里的i是存在于子块中的局部变量 i = 7; //局部变量赋值...

2020-03-15 14:10:05 101

原创 C++ 结构体、联合体

结构体是特殊形态的类,与类的区别:结构体的默认访问权限是public,也就是说当你创建数据成员的时候,默认是属于public类,存在的主要原因:与C语言保持兼容。//结构体 struct 学生信息#include <iostream>#include <iomanip>#include <string>using namespace std;s...

2020-03-15 13:50:14 182

原创 Understanding the concept of inheritance in C++

Inheritance is a characteristic of C++. In the real world, we know that children may inherit something from their parents like genes or appearance,etc.Basically, in C++,supposed that there are two cla...

2020-03-12 16:11:57 106

原创 friend function in C++

If you add friend before creating the funciton, then you have a friend function.When you create a friend function,you should put it in a class, so that the system know this function is a friend of th...

2020-03-12 15:54:51 128

原创 C++第一次作业

类和对象练习作业1、设计一个类Tree,包括成员变量ages。成员函数:(1)grow(int years)对ages加上years(2)age()显示tree对象的ages的值。编译Tree类和 创建TestTree对象,测试Tree类。 必须获得以下结果:这棵树50岁35年后,这棵树85岁代码:#include <iostream>using namespace...

2020-03-12 15:47:26 602

原创 C++函数调用参数的问题

昨天晚上做C++作业的时候出现了关于函数调用参数的问题,和同学讨论了下,发现是我把简单的东西复杂化了。作业题目如下:3、定义一个表示学生信息的类Student,要求如下:(1)类Student的成员变量:sNo 表示学号;sName表示姓名;sSex表示性别;sAge表示年龄;sCplus:表示C++课程成绩。(2)类Student带参数的构造方法:在构造方法中通过形参完成对成员变量的...

2020-03-12 15:39:40 895

原创 The friend function in C++

The friend function can totally separate from the class but it can still have acess to the information inside the class whatever it is private or publicLook at a piece of code:#include <iostream&...

2020-03-04 00:22:33 118

原创 the composition of class and object in C++

Thanks to the tutorials on Youtube,yesterday I finally figured out how the composition of class and object works, which has confused me for a long time.Let me explain it by analyzing a piece of code....

2020-03-04 00:07:25 173

原创 c++中形式参数和实际参数的问题

今天做c++例题的时候发现一个问题有以下问题输入两个整数后交换并输出结果以下是原代码:#include <iostream>using namespace std;void swap(int a, int b ){ int t = a; a = b; b = t;}int main(){ int x = 5, y = 10; cout << "x...

2020-02-22 20:59:02 883

原创 关于位移符号在循环语句中的使用

有以下这段代码:#include <iostream>#include <bitset>using namespace std;int main(){ cout << "~15= " << (~15) << endl; //~表示二进制每位都取反 cout << "15&21= " << (1...

2020-02-20 18:03:02 161

原创 关于 “=” “-” 和 “++”或“--”的优先顺序

对于这段代码//赋值运算的应用#include <iostream>using namespace std;int main(){ int ival1; int ival2; double fval; char cval; ival1 = 1; ival2 = 2; cout << "ival1= " << ival1 <<...

2020-02-20 15:59:50 3317

原创 关于 c++语言中 ++和--的前后问题

今天在学习 c++的算术运算中发现如下问题// 算术运算#include <iostream>using namespace std;int main(){ int val1 = 24; int val2 = 5; double val3 = 24; double val4 = 5; cout << "int/int,24/5 = " << ...

2020-02-20 15:31:29 419

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除