persontype.h

来自「data+structures+using+c的源码」· C头文件 代码 · 共 49 行

H
49
字号
#ifndef H_personType
#define H_personType

#include <iostream>
#include <string>

using namespace std;


class personType 
{
        //Overload the stream insertion and extraction operators.     
	friend istream& operator>>(istream&, personType&);
    friend ostream& operator<<(ostream&, const personType&);

public:
    const personType& operator=(const personType&);
	//Overload the assignment operator.

    void setName(string first, string last);
	//Function to set firstName and lastName according to 
 	//the parameters.
	//Postcondition: firstName = first; lastName = last

    void getName(string& first, string& last);
	//Function to return firstName and lastName via the 
  	//parameters. 	//Postcondition: first = firstName; last = lastName      
	
	personType(string first = "", string last = ""); 	
	//constructor with parameters 	
	//Set firstName and lastName according to the parameters.
	//Postcondition: firstName = first; lastName = last

	  //Overload the relational operators.
    bool operator==(const personType& right) const;
    bool operator!=(const personType& right) const;
    bool operator<=(const personType& right) const;
    bool operator<(const personType& right) const;
    bool operator>=(const personType& right) const;
    bool operator>(const personType& right) const;

protected:
    string firstName; //variable to store the first name
    string lastName;  //variable to store the last name
};


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?