这是一个记录贴,记录一下我在b站学习数据结构课程的作业和一些小小的心得。视频课程是懒猫老师的,老师真的讲得很细,也很认真,附上链接:https://www.bilibili.com/read/cv8013121;这是一个专栏链接,里面记录了每一个课程,都可以点进去看(三连走起!)
首先是第一个作业:用单链表完成一个学生管理系统
头文件:
node.h
#pragma once
//#include <iostream>
//using namespace std;
#ifndef NODE_H
#define NODE_H
template<class T>
// 结点类
class Node
{
public:
T data;
Node* next;
};
#endif // !NODE_H
student.h
#pragma once
#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
using namespace std;
// 学生类
class Student
{
public:
string m_Name;
int m_ID;
};
#endif // !STUDENT_H
studentManager.h
#pragma once
#ifndef STUDENGMANAGER_H
#define STUDENTMANAGER_H
#include <iostream>
using namespace std;
#include "student.h"
#include "node.h"
class studentManager
{
public:
// 构造函数
studentManager();
// 显示菜单
void showMenu();
// 退出系统
void exitSystem();
// 创建并输入学生结点
void creatStudent(Node<Student>* head);
// 显示学生记录
void showStudent(Node<Student>* head);
// 利用学号查找学生结点
Node<Student>* findNode(Node<Student>* head, int val);
// 插入学生结点
bool insertNode(Node<Student>* head, Node<Student>* stunode);
// 删除学生记录
bool deleteStudent(Node<Student>* head);
// 查找学生记录
void findStudent(Node<Student>* head);
// 修改学生记录
void modifyStudent(Node<Student>* head);
// 析构函数
~studentManager();
private:
// 属性
// 学生结点
//Node<Student>* stunode;
public:
// 学生人数
int m_Num;
};
#endif // !STUDENGMANAGER_H
源文件:
studentManager.cpp
#include "studentManager.h"
#include <cstdlib>
// 构造函数
studentManager::studentManager()
{
this->m_Num = 0;
}
// 显示菜单
void studentManager::showMenu(