上一页 1 2 3 4 5 6 7 ··· 13 下一页
摘要: private成员总是严格私有的,但在实际项目中,有时希望某些东西隐藏起来,但仍允许其 派生类的成员访问。于是关键字protected派上了用场。它的意思是:“就这个类的用户而 言,它是private的,但它可被从这个类继承来的任何类使用”。 最好让数据成员是private,因为我们应该保留改变内部 阅读全文
posted @ 2021-01-26 22:53 诗和远方* 阅读(635) 评论(0) 推荐(0) 编辑
摘要: 当私有继承时,基类的所有public成员都变成了private。如果希望它们中的任何一个 是可视的,只要用派生类的public部分声明它们的名字即可: #include<iostream>using namespace std; class Pet {public: char eat() const 阅读全文
posted @ 2021-01-26 22:03 诗和远方* 阅读(136) 评论(0) 推荐(0) 编辑
摘要: // constructor/destructor order #include<fstream>#include<iostream>using namespace std; #define CLASS(ID) class ID{\public:\ ID(int) {cout <<#ID<<" co 阅读全文
posted @ 2021-01-26 17:18 诗和远方* 阅读(164) 评论(0) 推荐(0) 编辑
摘要: //:C11:Combined.cpp// Inheritance & composition#include<iostream>using namespace std; class A { int i;public: A (int ii) : i(ii) {cout << "run A()"<<' 阅读全文
posted @ 2021-01-26 16:12 诗和远方* 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 当继承时,我们会发现“这个新类很像原来的类”。我们规定,在代码中和原来一样给 出该类的名字,但在类的左括号的前面,加一个冒号和基类的名字(对于多重继承,要给 出多个基类名,它们之间用逗号分开)。当做完这些时,将会自动地得到基类中的所用数 据成员和成员函数。下面是一个例子: //Useful.h #d 阅读全文
posted @ 2021-01-26 11:16 诗和远方* 阅读(255) 评论(0) 推荐(0) 编辑
摘要: struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int value):val(value),left(nullptr),right(nullptr){} }; class SearchTreeNode { pub 阅读全文
posted @ 2020-11-20 17:01 诗和远方* 阅读(283) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void rotate(vector<vector<int>>& matrix) { vector<vector<int>> res; vector<int> ans; if(matrix.empty()) { return ; } int top  阅读全文
posted @ 2020-11-20 16:57 诗和远方* 阅读(358) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>#include<stack>using namespace std; class Solution{public: string reverseWords(string s){ int left = 0,right = s.siz 阅读全文
posted @ 2020-11-14 21:19 诗和远方* 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 参考博文链接:https://www.cnblogs.com/sghy/p/7827255.html 1.For循环 格式: for( 初始语句 ; 执行条件 ; 增量 ){ 循环体 } 执行顺序:1、初始语句 2、执行条件是否符合 3、循环体 4、增加增量 初始化语句只在循环开始前执行一次,每次执 阅读全文
posted @ 2020-11-10 16:22 诗和远方* 阅读(3209) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) :  阅读全文
posted @ 2020-11-06 17:32 诗和远方* 阅读(344) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 13 下一页