数据结构与算法课程记录——单链表作业1:学生管理系统

这篇博客记录了作者在B站学习数据结构课程时,使用单链表完成学生管理系统作业的过程。作业涉及到`node.h`、`student.h`、`studentManager.h`等头文件及`studentManager.cpp`源文件的编写,但`studentManager`类的析构函数有待完善,以防止内存泄漏。
摘要由CSDN通过智能技术生成

这是一个记录贴,记录一下我在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(
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值