home *** CD-ROM | disk | FTP | other *** search
- #include "student.h"
- #include "studutes.h"
- #include <iomanip>
- #include <string>
- #include <cstdlib>
-
- CStudent::CStudent()
- : m_studNo(0)
- {
- }
-
-
- CStudent::CStudent(unsigned sNo,
- const std::string &fNam,
- const std::string &oNam,
- const std::string &addr,
- const std::string &DOB)
- : m_studNo(sNo)
- , m_familyName(fNam)
- , m_otherNames(oNam)
- , m_address(addr)
- , m_DOB(DOB)
- {
- }
-
- unsigned CStudent::StudentNo() const
- {
- return m_studNo;
- }
-
- const std::string &CStudent::FamilyName() const
- {
- return m_familyName;
- }
-
- const std::string &CStudent::OtherName() const
- {
- return m_otherNames;
- }
-
- const std::string &CStudent::Address() const
- {
- return m_address;
- }
-
- const std::string &CStudent::DOB() const
- {
- return m_DOB;
- }
-
- bool CStudent::Read(std::ifstream &is)
- {
- SStudent s;
-
- is.read(reinterpret_cast<char *>(&s),
- sizeof(SStudent));
- m_studNo = s.m_studNo;
- m_familyName = s.m_familyName;
- m_otherNames = s.m_otherNames;
- m_address = s.m_address;
- m_DOB = s.m_DOB;
-
- return is.good();
- }
-
- bool CStudent::Write(std::ofstream &os)
- {
- SStudent s;
-
- s.m_studNo = m_studNo;
- StudUtes::SafeCopy(s.m_familyName,
- m_familyName.c_str(),
- LENSTR);
- StudUtes::SafeCopy(s.m_otherNames,
- m_otherNames.c_str(),
- LENSTR);
- StudUtes::SafeCopy(s.m_address,
- m_address.c_str(),
- LENSTR);
- StudUtes::SafeCopy(s.m_DOB,
- m_DOB.c_str(),
- LENDOB);
-
- //os << std::ios_base::binary;
- os.write(reinterpret_cast<char *>(&s),
- sizeof(SStudent));
- return os.good();
- }
-
- bool CStudent::Print(std::ostream &os)
- {
- os << m_studNo << std::endl
- << m_familyName << std::endl
- << m_otherNames << std::endl
- << m_address << std::endl
- << m_DOB << std::endl;
- return os.good();
- }