模拟人生3补丁怎么安装:c++ 编程问题

来源:百度文库 编辑:中科新闻网 时间:2024/05/06 20:07:02
Question 3.
//*****************************************************************
// SPECIFICATION FILE (Name.h)
// This file gives the specification of the Name abstract data
// data type. There are two constructors: one takes the first,
// middle, and last name as parameters and the second sets first,
// middle, and last name to blanks
//*****************************************************************
#include <iostream>
#include <string>
using namespace std;
enum RelationType{BEFORE, SAME, AFTER};
class Name
{
public:
Name();
// Default constructor
// Postcondition:
// first, middle, and last have been set to blanks
Name( /* in */ string firstName,
/* in */ string middleName,
/* in */ string lastName );
// Parameterized constructor
// Postcondition:
// first is firstName AND middle is middleName AND
// last is lastName
void SetName( /* in */ string firstName,
/* in */ string middleName,
/* in */ string lastName );
// Postcondition:
// first is firstName AND middle is middleName AND
// last is lastName
void ReadName();
// Postcondition:
// Name is prompted for and read from the standard input
// device
string FirstName() const;
// Postcondition:
// Return value is this person's first name
string LastName() const;
// Postcondition:
// Return value is this person's last name
string MiddleName() const;
// Postcondition:
// Return value is this person's middle name
char MiddleInitial() const;
// Postcondition:
// Return value is this person's middle initial
RelationType ComparedTo( /* in */ Name otherName ) const;
// Postcondition:
// Return value is
// BEFORE, if this name comes before otherName
// SAME, if this name and otherName are the same
// AFTER, if this name is after otherName
private:
string first; // Person's first name
string last; // Person's last name
string middle; // Person's middle name
};
3.1 Implement this class by providing complete declarations and definitions.

3.2 Implement this class by removing the functions from the class and putting the data members into a structure. The structure should contain variables that permit the storage of a name: string first, string last, and string middle. Show how structure objects can be stored in a list or a vector as they are created using a small program.

3.1 和3.2 是问题希望能给个准确答案如果有参考知识点的话请标注谢谢大家的热心帮助。
本人在线等希望大家不吝赐教