资源简介
C++程序设计课程的作业,允许使用STL。功能要求是,有注册学生、注册课程、选课、退课的功能。大体实现思路是,对于每个课程和学生,用map保存其信息,灵活方便;为实现注册功能,用指针线性表管理学生和课程,方便动态创建和统一析构;为实现选课和退课功能,维护学生和课程之间的二元关系及其逆关系(用指针序偶的集合实现)。可见,学生信息和课程信息在内存中是唯一的,选课和退课的操作都是对指针进行的,节省内存。注意,与硬盘交互的文件功能可能存在问题。
代码片段和文件信息
#include “pch.h“
#include “Course.h“
#include
const char Course::signature[30] = { “Course“ };
Course::Course()
{
info[“ID“];
info[“name“];
info[“teacher“];
info[“domain“];
info[“time“];
info[“credit“];
info[“evaluation mode“];
}
Course::operator MyString() const
{
MyString _str(signature);
_str.append(“ “);
for (auto it = info.cbegin();
it != info.cend(); it++)
{
_str.append(“{“);
_str.append(it->first);
_str.append(“: “);
_str.append(it->second);
_str.append(“} “);
}
return _str;
}
Course::~Course()
{
}
Course::Course(const Course & c)
{
ID = c.ID;
info = c.info;
}
Course & Course::operator=(const Course & c)
{
ID = c.ID;
info = c.info;
return *this;
}
void Course::init()
{
std::cout << signature << std::endl;
MyString value;
for (auto it = info.begin();
it != info.end(); it++)
{
std::cout << it->first << “: “;
getline(std::cin value);
info[it->first] = value;
}
ID = info[“ID“];
}
void Course::save(std::ofstream & os) const
{
os << signature << std::endl;
for (auto it = info.cbegin(); it != info.cend(); it++)
os << “{“ << it->first << “:“ << it->second << “} “;
os << std::endl;
}
void Course::restore(std::ifstream & is)
{
std::streampos pos = is.tellg();
char buff[300];
char key[120];
char value[130];
MyString sig;
getline(is sig);
if (sig ==
MyString(signature))
{
is.getline(buff 300);
std::stringstream ss(buff);
ss.ignore(300 ‘{‘);
while (!ss.eof())
{
ss.getline(key 120 ‘:‘);
ss.getline(value 130 ‘}‘);
info[MyString(key)] = MyString(value);
ss.ignore(300 ‘{‘);
}
ID = info[“ID“];
}
else
is.seekg(pos);
}
MyString Course::getID() const
{
return ID;
}属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-22 08:59 CourseSelectionSystem\
目录 0 2018-12-18 22:22 CourseSelectionSystem\.vs\
目录 0 2018-12-18 22:22 CourseSelectionSystem\.vs\CourseSelectionSystem\
目录 0 2018-12-28 19:49 CourseSelectionSystem\.vs\CourseSelectionSystem\v15\
文件 91648 2018-12-28 19:49 CourseSelectionSystem\.vs\CourseSelectionSystem\v15\.suo
文件 5967872 2018-12-28 19:49 CourseSelectionSystem\.vs\CourseSelectionSystem\v15\Browse.VC.db
目录 0 2018-12-28 19:43 CourseSelectionSystem\.vs\CourseSelectionSystem\v15\ipch\
文件 327680 2018-12-22 11:02 CourseSelectionSystem\.vs\CourseSelectionSystem\v15\ipch\3d84e2152de53b30.ipch
文件 327680 2018-12-28 19:44 CourseSelectionSystem\.vs\CourseSelectionSystem\v15\ipch\a75d1391a2f1a14f.ipch
目录 0 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\
文件 1476 2018-12-18 22:22 CourseSelectionSystem\CourseSelectionSystem.sln
文件 1814 2018-12-28 10:05 CourseSelectionSystem\CourseSelectionSystem\Course.cpp
文件 460 2018-12-22 08:12 CourseSelectionSystem\CourseSelectionSystem\Course.h
文件 147 2018-12-20 15:17 CourseSelectionSystem\CourseSelectionSystem\courses.txt
文件 6027 2018-12-28 10:04 CourseSelectionSystem\CourseSelectionSystem\CourseSelectionSystem.cpp
文件 1053 2018-12-22 11:23 CourseSelectionSystem\CourseSelectionSystem\CourseSelectionSystem.h
文件 8945 2018-12-19 14:06 CourseSelectionSystem\CourseSelectionSystem\CourseSelectionSystem.vcxproj
文件 2335 2018-12-19 14:06 CourseSelectionSystem\CourseSelectionSystem\CourseSelectionSystem.vcxproj.filters
文件 165 2018-12-18 22:22 CourseSelectionSystem\CourseSelectionSystem\CourseSelectionSystem.vcxproj.user
目录 0 2018-12-28 10:05 CourseSelectionSystem\CourseSelectionSystem\Debug\
文件 619021 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\Course.obj
目录 0 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\
文件 15506 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\CL.command.1.tlog
文件 144078 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\CL.read.1.tlog
文件 7784 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\CL.write.1.tlog
文件 225 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\CourseSelectionSystem.lastbuildstate
文件 5938 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\li
文件 5988 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\li
文件 1980 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSe.7C65D630.tlog\li
文件 408 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSelectionSystem.log
文件 850299 2018-12-28 10:06 CourseSelectionSystem\CourseSelectionSystem\Debug\CourseSelectionSystem.obj
............此处省略29个文件信息
相关资源
- Deep Belief Nets in C++ and CUDA C Volume 2 Au
- C++获取计算机的CPU ID,硬盘序列号等
- C++头文件转delphi工具 + 源码
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
川公网安备 51152502000135号
评论
共有 条评论