C++ 通讯录-改

#ifndef _ADDRESS_H
#define _ADDRESS_H

#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

class book
{
public:
	book();//默认无参构造
	void AddIn();
	void AddId();
	void AddName();
	void AddMobile();
	void AddTelephone();
	void Addaddr();
	void Print();
	string& getName();
	string& getMobile();
	string& getTele();
	string& getaddr();
	int& getid();

private:
	string name;      //姓名
	string mobile;     //手机
	string telephone; //电话号码
	string addr;      //地址
	int id;
};






#endif

#include "address.h"

book::book()
{


}

void book::AddIn()
{
	this->AddId();
	this->AddName();
	int flag = 1;
	while(flag)
	{
		try
		{
			this->AddMobile();

		}
		catch(int error)
		{
			if(error == 10001)
			{
				cout << "电话号码不足11位" <<endl;
				flag = 1;
			}
			else if(error == 10002)
			{
				flag = 0;
			}
		}
	}
	this->AddTelephone();
	this->Addaddr();

}

void book::AddId()
{
	cout<<"请输入您的序号"<< endl;
	cin >>this->id;

}
void book::AddName()
{
	cout<<"请输入您的姓名"<<endl;
	cin>>this->name;
}
void book::AddMobile()
{
	int ERROR = 10001,SUCCESS =10002;
	cout<<"请输入您的手机号码"<<endl;
	cin>>this->mobile;
	if(this->mobile.length()!= 11)
		throw ERROR;
	else
		throw SUCCESS;
}
void book::AddTelephone()
{

	cout<<"请输入您的住宅
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值