![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
妮推
这个作者很懒,什么都没留下…
展开
-
单链表的运用&运算符重载——多项式相加
编译环境:VS2017#poly.h#pragma once#include<iostream>using namespace std;class Node{public: int coe;//系数 int ind;//指数 Node *next;};class Poly{private: Node *head;public: Poly();//...原创 2019-04-04 14:35:57 · 1965 阅读 · 0 评论 -
面向对象程序设计示例
1.家庭中体育锻炼类的设计(据说某届DLUT期末考题)分析:主要有两个类 成员(Members)和 家庭(Family);其中的成员类(Members)派生出多个子类:爸爸(Father)、妈妈(Mother)、儿子、隔壁老王、花Q等等,并且后续可以添加;成员类(Members)中有一个纯虚函数 运动(sports),在其子类中有不同的实现方法;家庭类(Family)中包含 ...原创 2019-05-08 20:36:22 · 1268 阅读 · 0 评论 -
安全数组设计实例
#include<iostream>using namespace std;class IntArray{public: IntArray(int s = 0); ~IntArray(); int & operator [](int i); IntArray & operator =(const IntArray & a); friend o...原创 2019-05-09 16:33:05 · 265 阅读 · 0 评论 -
栈的简单模拟 及 四则运算
#include <iostream>using namespace std;const int Max = 20;template < class T>class stack{ T s[Max]; int top;public: stack() { top = 0; } void push(T x) { if (top < 20) s[top+...原创 2019-05-09 16:45:34 · 212 阅读 · 0 评论 -
递归法求链表的最大值、结点数、平均值
已知head为单链表的表头指针,链表中存储的都是整型数据,实现下列运算的算法:(1) 求链表中的最大值(2)求链表中的结点个数(3)求所有整数的平均值#include<iostream>#include<algorithm>using namespace std;class ListNode{public: int val; ListNod...原创 2019-09-13 11:37:50 · 4785 阅读 · 2 评论 -
LeetCode 上遇到 runtime error 错误
问题描述: 在LeetCode上做链表有关题目时,代码提交时出现如下错误: runtime error: member access with null pointer of type 'struct ListNode'(solution.cpp) 运行时错误: 成员访问了空指针指向的结构体类型'struct ListNode'如下图:...原创 2019-09-23 15:34:46 · 1030 阅读 · 0 评论