CPP icon indicating copy to clipboard operation
CPP copied to clipboard

Lecture notes, projects and other materials for Course 'CS205 C/C++ Program Design' at Southern University of Science and Technology.

Results 22 CPP issues
Sort by recently updated
recently updated
newest added

这是我在于老师2020秋季学C/C++程序设计的所有project和作业的代码开源链接,总评91分,为A-等级,供各位上于老师C/C++课的同学们参考:https://github.com/YeeTone/CS205-2020Fall

# Issue1 https://github.com/ShiqiYu/CPP/blob/14c70552862fffb0463e596607ff6f95dcd6d804/week12/examples/derived-memory/mystring.hpp#L68 派生访问说明符拼写错了,应该是 `public` 而不是 `pubic` 。 # Issue2 https://github.com/ShiqiYu/CPP/blob/14c70552862fffb0463e596607ff6f95dcd6d804/week12/examples/derived-memory/mystring.hpp#L76-L80 1. 派生类的构造函数、拷贝构造函数和拷贝赋值运算符通常应该是 `public` 而不需要是 `private` 。 2. 派生类的拷贝构造函数的规范实现应该是调用基类的拷贝构造函数来进行初始化派生类对象的基类部分,课件这里,调用基类的普通构造函数是不合适的,并且程序也是无法通过编译的,因为基类MyString的数据成员是 `private` 的,所以派生类MyMap是无法直接访问基类的 `buf_len` 和 `characters` 数据成员的。 派生类MyMap的拷贝构造函数的规范实现代码如下: ```cpp public: MyMap(const MyMap&...

https://github.com/ShiqiYu/CPP/blob/14c70552862fffb0463e596607ff6f95dcd6d804/week12/examples/virtual.cpp#L5-L14 The class Person doesn't have a user-written virtual destructor, so its destructor defaults to public non-virtual. https://github.com/ShiqiYu/CPP/blob/14c70552862fffb0463e596607ff6f95dcd6d804/week12/examples/virtual.cpp#L49-L51 The result of `delete p;` is undefined behavior, so it might call...

https://github.com/ShiqiYu/CPP/blob/8d450448b8006f82fed677deb0d3639bf2226915/week11/examples/example2/mystring.hpp#L29-L48 # Issue1: can't handle self-assignment See: [Assignment Operators, C++ FAQ (isocpp.org)](https://isocpp.org/wiki/faq/assignment-operators) If `x = x` , bad errors will occur. We can handle self-assignment by explicitly testing for self-assignment:...

https://github.com/ShiqiYu/CPP/blob/8d450448b8006f82fed677deb0d3639bf2226915/week11/examples/unique_ptr.cpp#L56 课件这里,其实可以这样进行拷贝: `std::unique_ptr mt3 = std::make_unique(*mt1);` 虽然 `std::unique_ptr` 删除了 copy constructor 和 copy assignment operator ,但其实我们可以借助解引用操作变通地对 `std::unique_ptr` 进行拷贝。 deep copy 示例如下: ```cpp std::unique_ptr up1(std::make_unique("Good morning")); // copy construct! std::unique_ptr up2(std::make_unique(*up1));...

In my machine ```bash $ uname -a Linux DELL-Inspiron7580 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ``` `init.cpp` output is ```bash num1 = 0...