uacs2024

导航

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 24 下一页

2024年3月10日 #

郑莉cpp例6-22 浅层复制与深层复制 动态数组类?动态类数组类?

摘要: 浅层复制与深层复制 浅层复制并没有形成真正的副本,存在两个对象共用同一块内存空间而导致执行析构函数时,该空间被两次释放,导致运行错误。 深层复制则实现,复制之后,两个对象不互相影响。 #include <iostream> using namespace std; #include <cassert 阅读全文

posted @ 2024-03-10 17:13 ᶜʸᵃⁿ 阅读(27) 评论(0) 推荐(0)

2024年3月9日 #

函数返回数组指针 看不太懂

摘要: 有三种方法 1.声明一个返回数组指针的函数 int (*func(int i)) [10]; func(int i) 表示调用func函数所需要一个int类型的实参。(*func(int i)) 意味着我们可以对函数调用的结果执行解引操作。 //意思就是函数调用的结果的是个指针。(*func(int 阅读全文

posted @ 2024-03-09 21:06 ᶜʸᵃⁿ 阅读(155) 评论(0) 推荐(0)

2024年3月8日 #

子类包含父类成员的构造与析构顺序

摘要: 子类包含父类成员的构造与析构顺序 #include <iostream> using namespace std; class F1{ public: F1() {cout << "F1 构造函数" << endl;} ~F1() {cout << "F1 析构函数" << endl;} }; cl 阅读全文

posted @ 2024-03-08 14:45 ᶜʸᵃⁿ 阅读(18) 评论(0) 推荐(0)

复试C++ 异常 看程序写结果

摘要: 就算每一个case后面都没有break , throw相当于起了break的作用? #include <iostream> #include <stdexcept> using namespace std; class ErrorA: public runtime_error{ public: Er 阅读全文

posted @ 2024-03-08 10:57 ᶜʸᵃⁿ 阅读(9) 评论(0) 推荐(0)

2024年3月7日 #

leetcode120. 三角形最小路径和

摘要: leetcode120. 三角形最小路径和 这道题的关键在于想到 dp[i][j] = min(dp[i-1][j-1] , dp[i-1][j]) + triangle[i][j]; 太久没做过算法题了,连设一个dp数组都没意识到 我的代码 class Solution { public: int 阅读全文

posted @ 2024-03-07 17:43 ᶜʸᵃⁿ 阅读(9) 评论(0) 推荐(0)

2024年3月6日 #

带析构语义的类的C++异常处理

摘要: C++异常处理 #include <iostream> #include <string> using namespace std; class MyException { public: MyException(const string &message):message(message){} ~ 阅读全文

posted @ 2024-03-06 22:03 ᶜʸᵃⁿ 阅读(7) 评论(0) 推荐(0)

C++派生类构造函数与析构函数

摘要: 实例 #include <iostream> using namespace std; class Base1 {//基类Base1,构造函数有参数 public: Base1(int i) { cout << "Constructing Base1 " <<i<< endl; } ~Base1() 阅读全文

posted @ 2024-03-06 18:22 ᶜʸᵃⁿ 阅读(17) 评论(0) 推荐(0)

2024年3月5日 #

类继承的合法调用

摘要: #include <iostream> using namespace std; class A1{ public: void show1() { cout << "class A1" << endl; } }; class A2 : public A1{ void show2() { cout < 阅读全文

posted @ 2024-03-05 10:48 ᶜʸᵃⁿ 阅读(5) 评论(0) 推荐(0)

利用指针遍历数组

摘要: #include <cstddef> #include <iostream> using namespace std; int main() { int arr[6] = { 0 , 1 , 2 , 3 , 4 , 5 }; int* ptr = arr; int len = sizeof(arr) 阅读全文

posted @ 2024-03-05 10:37 ᶜʸᵃⁿ 阅读(6) 评论(0) 推荐(0)

2024年3月4日 #

c++在类外是不能直接调用私有成员函数的

摘要: c++在类外是不能直接调用私有成员函数的,比如 #include <iostream> using namespace std; class A3 { void show3() { cout << "class A3"<< endl; //注意,类内部默认是私有 } }; int main() { 阅读全文

posted @ 2024-03-04 21:18 ᶜʸᵃⁿ 阅读(255) 评论(0) 推荐(0)

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 24 下一页