09 2022 档案

摘要:1.静态成员函数是不能使用 this 指针,因为静态成员函数相当于是共享的变量,不属于某个对象的变量 2.友元函数友元类C++友元函数和友元类(C++ friend关键字) (biancheng.net) 阅读全文
posted @ 2022-09-19 16:29 balabalahhh 阅读(246) 评论(0) 推荐(0) 编辑
摘要:1.这里的数字与ASCII码是对应的 1 #include <stdio.h> 2 3 int main(){ 4 char s[7] = {1,2,0,2,0,3}; 5 if(s[2] == 0) printf("%d",s[2] - '0'); 6 return 0; 7 } 输出为 -48: 阅读全文
posted @ 2022-09-18 22:58 balabalahhh 阅读(77) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 6 struct A { 7 int v; 8 A() { } 9 A(int n):v(n) { }; 10 bool operator<(const A & 阅读全文
posted @ 2022-09-13 22:59 balabalahhh 阅读(313) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <cmath> 3 #include <algorithm> 4 #include <string> 5 using namespace std; 6 template <class T1,class T2> 7 struct Clo 阅读全文
posted @ 2022-09-13 22:56 balabalahhh 阅读(191) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 bool Greater2(int n1,int n2) 5 { 6 return n1 > n2; 7 } 8 bool Greater1(int n1,int n2) 9 { 10 return n 阅读全文
posted @ 2022-09-13 22:55 balabalahhh 阅读(153) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 template <class T> 6 class CMyistream_iterator 7 { 8 private: 9 istream& in; 10 T 阅读全文
posted @ 2022-09-13 22:54 balabalahhh 阅读(187) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 #include <cstring> 4 using namespace std; 5 template <class T> 6 class myclass { 7 private: 8 T* p; 9 int 阅读全文
posted @ 2022-09-13 22:54 balabalahhh 阅读(399) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class MyCin 4 { 5 bool value; 6 public: 7 MyCin():value(true){ } 8 operator bool(){return value;} 9 MyC 阅读全文
posted @ 2022-09-13 22:53 balabalahhh 阅读(33) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 using namespace std; 4 template<class T,class Pred> 5 T* Filter(T* p,T* q,T* s,Pred op){ 6 while(p < q){ 7 阅读全文
posted @ 2022-09-13 22:52 balabalahhh 阅读(56) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 using namespace std; 4 template<class T,class Pred> 5 void MyForeach(T *p,T *q,Pred op){ 6 while(p != q){ 阅读全文
posted @ 2022-09-13 22:52 balabalahhh 阅读(81) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 using namespace std; 4 template <class T> 5 T SumArray( 6 T *p,T *q){ 7 T sum = *p; 8 while(++ p != q) 9 s 阅读全文
posted @ 2022-09-13 22:51 balabalahhh 阅读(147) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class A { 4 private: 5 int nVal; 6 public: 7 void Fun() 8 { cout << "A::Fun" << endl; }; 9 virtual void 阅读全文
posted @ 2022-09-13 22:51 balabalahhh 阅读(78) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class A 4 { 5 public: 6 A() { } 7 virtual ~A() { cout << "destructor A" << endl; } 8 }; 9 class B:publi 阅读全文
posted @ 2022-09-13 22:50 balabalahhh 阅读(12) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class B { 4 private: 5 int nBVal; 6 public: 7 void Print() 8 { cout << "nBVal="<< nBVal << endl; } 9 vo 阅读全文
posted @ 2022-09-13 22:49 balabalahhh 阅读(36) 评论(0) 推荐(0) 编辑
摘要:1 #include <cstdlib> 2 #include <iostream> 3 using namespace std; 4 int strlen(const char * s) 5 { int i = 0; 6 for(; s[i]; ++i); 7 return i; 8 } 9 vo 阅读全文
posted @ 2022-09-13 22:46 balabalahhh 阅读(69) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 using namespace std; 6 const int MAX = 110; 7 class CHugeInt { 8 阅读全文
posted @ 2022-09-13 22:43 balabalahhh 阅读(53) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 5 class Array2 { 6 private: 7 int** arr; 8 int row,col; 9 public: 10 Array2(int i 阅读全文
posted @ 2022-09-13 22:41 balabalahhh 阅读(37) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class Point { 4 private: 5 int x; 6 int y; 7 public: 8 Point() { }; 9 friend istream& operator>>(istrea 阅读全文
posted @ 2022-09-13 22:37 balabalahhh 阅读(36) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> using namespace std; class MyInt { int nVal; public: MyInt( int n) { nVal = n ;} MyInt& operator-(int x){ nVal -= x; return *this; 阅读全文
posted @ 2022-09-13 22:36 balabalahhh 阅读(21) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 #include <cstring> 4 using namespace std; 5 class MyString { 6 char * p; 7 public: 8 MyString(const char * 阅读全文
posted @ 2022-09-13 22:35 balabalahhh 阅读(39) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 using namespace std; 4 class Base { 5 public: 6 int k; 7 Base(int n):k(n) { } 8 }; 9 class Big 10 { 11 pub 阅读全文
posted @ 2022-09-13 22:33 balabalahhh 阅读(12) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class A { 4 public: 5 int val; 6 7 A(int 8 i = 123):val(i){}; 9 A& GetObj(){return *this;} 10 }; 11 int 阅读全文
posted @ 2022-09-13 22:32 balabalahhh 阅读(17) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class A { 4 public: 5 int i; 6 A(int x) { i = x; } 7 ~A(){cout << i << endl;} 8 }; 9 int main() 10 { 11 阅读全文
posted @ 2022-09-13 22:31 balabalahhh 阅读(19) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 using namespace std; 5 class Complex { 6 private: 7 double r,i; 8 public: 9 void Pri 阅读全文
posted @ 2022-09-13 22:30 balabalahhh 阅读(44) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <cstdio> #include <cstring> #include <sstream> #include <cstdlib> using namespace std; class Student { 阅读全文
posted @ 2022-09-13 22:27 balabalahhh 阅读(73) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int * a[] = { 7 NULL 8 }; 9 10 *a[2] = 123; 11 a[3][5] = 456; 12 if(! a[0] ) { 13 co 阅读全文
posted @ 2022-09-13 22:24 balabalahhh 阅读(35) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 int & 4 getElement(int * a, int i) 5 { 6 return a[i]; 7 } 8 int main() 9 { 10 int a[] = {1,2,3}; 11 get 阅读全文
posted @ 2022-09-13 22:20 balabalahhh 阅读(16) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 void swap( 5 int* &a,int* &b 6 ) 7 { 8 int * tmp = a; 9 a = b; 10 b = tmp; 11 } 12 int main() 13 { 14 阅读全文
posted @ 2022-09-13 22:19 balabalahhh 阅读(16) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 class A 4 { 5 public: 6 int x; 7 int getX() { return x; } 8 }; 9 void swap( 10 A& a,A& b 11 ) 12 { 13 i 阅读全文
posted @ 2022-09-13 22:18 balabalahhh 阅读(25) 评论(0) 推荐(0) 编辑
摘要:multiset和set区别在于 前者可包含重复元素 1.创建一个set变量set2 用来记录进入过整数集的整数(利用唯一性),multiset变量mset用来管理整数集的所有整数(可包括重复的) 1 #include <iostream> 2 #include <set> 3 #include < 阅读全文
posted @ 2022-09-13 10:29 balabalahhh 阅读(19) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/hhhhxxn/article/details/106059028 图片也是网上找的 阅读全文
posted @ 2022-09-10 19:44 balabalahhh 阅读(27) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 5 template <class T> 6 struct GoodCopy { 7 // 在此处补充你的代码 8 void operator()(T* p,T* q,T* r){ 9 int n = 阅读全文
posted @ 2022-09-10 17:17 balabalahhh 阅读(31) 评论(0) 推荐(0) 编辑
摘要:知识点1:static静态变量在类内声明,但必须在类外初始化 知识点2:构造函数不能是虚函数 为什么C++的构造函数不可以是虚函数,而析构函数可以是虚函数 - 知乎 (zhihu.com) 知识点3:如果基类构造函数里所有参数有缺省值,那么派生类函数可以不为其初始化,基类会自行用缺省值初始化变量 知 阅读全文
posted @ 2022-09-01 18:32 balabalahhh 阅读(79) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示