![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++ Primer Plus v6 exercise
文章平均质量分 75
record my written code and the solvement.
狗头鹰
这个作者很懒,什么都没留下…
展开
-
C++ Primer Plus 第六版 Chapter10 第五题
/stack.hprivate:int top;public:Stack();~Stack();#endif //!STACK_H_top = 0;i < MAX;i++)i < MAX;i++){}if (!isfull())elseif (!isempty())else。原创 2024-05-12 23:45:22 · 331 阅读 · 1 评论 -
C++ Primer Plus version 6 chapter 10 exercise 8
private:int num;public:simList();~simList();#endifi < Max;i++)//num = 0;{}if (!isfull())num++;i < num;i++)i < num;i++)return;int main()i < Max;原创 2024-05-13 16:03:06 · 342 阅读 · 0 评论 -
C++ Primer Plus v6 Chapeter 11 exercise 5&&6
因为五六题用的是同一个类,且彼此之间并不冲突。所以我在书上提供代码的基础上,同时进行五六题。要点在head file和method file, main file文件中主要是使用自己定义好的类和方法,使用循环(for/while)进行方法的验证。在main file文件中,我定义了两个数组,实际上可以使用new 动态分配内存空间,更节省内存,更高效,此处仅仅作为测试类的正确程度,所以使用比较笨拙的方法。原创 2024-05-16 15:42:33 · 627 阅读 · 1 评论 -
C++ Primer Plus v6 Chapter 12 exercise 2
此题目考察了 copy constructor, assignment constructor, friend function, conversion constructor,都是基础的内容,实际上并不困难。其中,String& String::operator+(const String& rh) 函数的实现是此题中的新颖点,有参考价值。原创 2024-05-27 22:42:09 · 456 阅读 · 1 评论 -
C++ Primer Plus 第六版 答案 个人版
/ plorg.hprivate:int CI;public:~plorg();#endif //!PLORG_H_CI = newci;return;CI = 0;int main()plorg obj1;",99};i < 2;i++)原创 2024-05-12 22:23:49 · 251 阅读 · 2 评论 -
C++ Primer Plus v6 Chapter 12 exercise 1
需要实现一个类,提供函数的定义,并写一个函数测试。因为private中存在一个char* 指针,需动态分配内存,在虚函数中释放,以免造成内存泄漏。因为private中存在指针,需要深拷贝,copy constructor 和 operator= 需要释放之前指向的内存空间,重新申请,重新赋值。注意 operator= 需做自赋值的检查。在main函数中,我使用了一个类的数组,一个指针数组——相对于其他部分,这两个数组花了我不少时间。原创 2024-05-27 19:51:03 · 308 阅读 · 1 评论 -
C++ Primer Plus Chapter 13 exercise 1&&2
simple example code fragment about derived class && base class, especially the copy constructor, operator= method and so on.原创 2024-05-27 13:33:37 · 182 阅读 · 3 评论