自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 二维数组类

//D:二维数组类#include <iostream>#include <cstring>using namespace std;class Array2 { // 在此处补充你的代码private: int** p;//二维数组两颗星 //助教大哥说可以只开一维数组,like a line int col, row;public: //构造函数 Array2(int x=0, int y=0) :col(x), row...

2022-03-28 16:12:36 202

原创 你真的搞清楚为啥 while(cin >> n) 能成立了吗?

//D:你真的搞清楚为啥 while(cin >> n) 能成立了吗?//因为类型转换#include <iostream>using namespace std;class MyCin{ // 在此处补充你的代码private: bool flag = 1;public: //MyCin():flag(1){} operator bool() { return flag;}//while中有判断bool型函数/变量...

2022-03-28 16:03:08 499

原创 简单的Filter

//C:简单的Filter#include <iostream>#include <string>using namespace std;// 在此处补充你的代码template<class T1,class T2>T1 *Filter(T1 *a, T1 *b, T1 *c, T2 f)//为什么模板名加*就可以了?? 哦因为返回值需要是string*p这样的//最后一个调用函数的写T2 f和 bool f(T2 d)都行,看来函数的形参不影

2022-03-28 16:02:26 189

原创 简单的foreach

//B:简单的foreach#include <iostream>#include <string>using namespace std;// 在此处补充你的代码template<class T1,class T2>//需要两个类型void MyForeach(T1 *a, T1 *b,void f(T2 t))//函数的返回值类型一样,形参类型不同,且每做一步调用一次函数很好用{for (T1 *i = a; i < b; ++.

2022-03-28 16:01:54 363

原创 简单的SumArray

//A:简单的SumArray#include <iostream>#include <string>using namespace std;template <class T>T SumArray(// 在此处补充你的代码T *a, T *b)//定义正常的就对了,不是引用 ///什么时候用引用{T sum = *a;for (T*i =a+1; i < b; ++i)//1.注意不要越界了,是<,不是<...

2022-03-28 16:01:23 374 1

原创 Point能这样输入输出

//C:惊呆!Point竟然能这样输入输出#include <iostream>using namespace std;class Point {private:int x;int y;public:Point() { };// 在此处补充你的代码//正常输入输出就行了friend istream& operator>>(istream& cin, Point& p){ cin >&g...

2022-03-28 16:00:30 220

原创 看上去好坑的运算符重载

//B:看上去好坑的运算符重载#include <iostream>using namespace std;class MyInt{int nVal;public:MyInt(int n) { nVal = n; }// 在此处补充你的代码MyInt& operator-(int n)//形参根据算式决定{ nVal -=n; return *this;}operator int() { return nVal;...

2022-03-28 15:57:42 115

原创 A:MyString

//MyString#include <iostream>#include <string>#include <cstring>using namespace std;class MyString {char* p;public:MyString(const char* s) { if (s) { p = new char[strlen(s) + 1]; strcpy(p, s); } else p = NULL;}...

2022-03-28 15:55:53 121

原创 A:Apple

#include <iostream>using namespace std;class Apple { // 在此处补充你的代码 451public: static int nTotalNumber;//静态函数需要静态变量 Apple() { ++nTotalNumber; } Apple(const Apple& a)//不写系统也默认会给复制构造函数 { //++nTotalNumbe...

2022-03-28 15:49:46 64

原创 D:奇怪的类复制

//D:奇怪的类复制#include <iostream>using namespace std;class Sample {public:int v;// 在此处补充你的代码Sample(int n=0) :v(n) {}//这边如果不写n=0,那么需要一个无参构造函数Sample(const Sample& s){v =s.v+2;}//Sample():v(0) {};};void PrintAndDouble(Sample o...

2022-03-27 01:23:39 127

原创 C:Big & Base 封闭类问题

//C:Big & Base 封闭类问题#include <iostream>#include <string>using namespace std;class Base {public:int k;Base(int n) :k(n) { }};class Big{public:int v;Base b;// 在此处补充你的代码Big(int n):v(n),b(n){}//注意的就是Base类里的构造...

2022-03-27 01:22:56 131

原创 B:返回什么才好呢

#include <iostream>using namespace std;class A {public:int val;A(int // 在此处补充你的代码n=123):val(n) {}//A():val(123) {}; 可以不写int &GetObj(){return val;}//main函数中作为左值,必须是引用operator int() { return val; };//必须要有返回值};int m...

2022-03-27 01:20:53 102

空空如也

空空如也

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

TA关注的人

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