这是我用C++编写的一个通讯论程序。请高手指点一二,其中的错误有几个,但是我实在是想不出改正的方法了。下面是代码,附件中也有源文件。小弟提前在此拜谢了。
//头文件AddressList.h
#define MaxSize 100
#include <iostream>
#include <string>
using namespace std;
class AddressList
{
public:
    AddressList(int i_1=0):i(i_1){}

    void DelAll();//清除文件中的所有内容
    void Display()const;//显示文件中的所有内容
    
    void Input();
    void Insert(int i,AddressList m);//向第i个位置插入该学生的记录
    void Delete( int i);//删除第i个学生的记录
    void Update( int i);//修改第i个学生的信息
    void Find( int i);//查询第i个学生的信息
public:
  static int length;
   int i;
private:
    string name;
    string telephone;
};

class AddressList1:public AddressList

 public:
    void Appearance();//显示主界面
};
class AddressList2:public AddressList1
{
public:
    void Login();//登陆本系统,如果成功,则进入,否则显示密码错误
};
//功能实现文件AddressList.cpp
#include <iostream>
#include <string>
#include <fstream>
#include "AddressList.h"
using namespace std;
int AddressList::length=0;
void AddressList::DelAll()
{
  ofstream fileout ;
  fileout.open("AddressList.txt",ios::out);
  if(!fileout)
  {
      cout<<"无法打开文件,出现错误!"<<endl;
      abort();
  }
  fileout.close();
}
void AddressList::Input()
{
    AddressList add[MaxSize];
    ofstream outfile("AddressList.txt",ios::app);
    if(!outfile)
    {
        cout<<"不能写入数据,信息有错误"<<endl;
        abort();
    }
    int n;
    cout<<"请输入要存储的数据记录数:";
    cin>>n;
    cout<<"请输入要插入的数据"<<endl;
    for(int i=0;i<n;i++)
    {
        cout<<"姓名:";cin>>add[i].name;outfile<<add[i].name<<"  ";
        cout<<"电话:";cin>>add[i].telephone;outfile<<add[i].telephone<<endl;
    }
}
void AddressList::Insert(int i,AddressList e)
{   
    AddressList add[MaxSize];
    ifstream infile("AddressList.txt",ios::in);
    if(!infile)
    {
        cout<<"不能写入数据,信息有错误"<<endl;
        abort();
    }
    infile.seekg(ios::beg);//将文件指针移动到文件开头位置
    for(int j=0;j<length;j++)
    {
        infile>>add[i].name;cout<<add[i].name;
        infile>>add[i].telephone;cout<<add[i].telephone;

    }                      //将数据从磁盘中读入一个数组中,并且存储。
    infile.close();

    if(i<1||i>length+1)  //插入数据
       abort();
    i--;
    cout<<"请输入要插入的数据"<<endl;
    cout<<"姓名:";cin>>e.name;
    cout<<"电话:";cin>>e.telephone;
    for( j=length;j>i;j--)
    {
        add[j].name=add[j-1].name;
        add[j].telephone=add[j-1].telephone;
    }
    add[i].name=e.name;
    add[i].telephone=e.telephone;  
    length++;
    
    ofstream outfile("AddressList.txt",ios::out);//写入文件中
    for(j=0;j<length;j++)
    { outfile<<add[i].name<<"  "<<add[i].telephone<<endl;}
      outfile.close();
    
}
//void AddressList::Display()
        
void AddressList1:: Appearance()
{   AddressList a;
    int choice;
do{
    cout<<"-----------登陆成功!欢迎您进入本系统-------------"<<endl;
    cout<<"--------1.输入记录------------"<<endl;
    cout<<"--------2.增加记录------------"<<endl;
    cout<<"--------3.删除记录------------"<<endl;
    cout<<"--------4.修改记录------------"<<endl;
    cout<<"--------5.查询记录------------"<<endl;
    cout<<"--------6.清空记录文件--------"<<endl;
    cout<<"--------7.显示信息------------"<<endl;
    cout<<"------------------------------"<<endl;
    cout<<"请输入您的选择:"<<endl;
    cin>>choice;
    switch(choice)
    {
    case 1:
        a.Input();
        break;
    case 2:
        a.Insert(2,a);
        break;
    case 3:
    //    a.Delete(a.i);
        break;
    case 4:
    //    a.Update(a.i);
        break;
    case 5:
    //    a.Find(a.i);
        break;
    case 6:
        a.DelAll();
        break;
    case 7:
    //    a.Display();
        break;
    }
}while(choice!=0);
}
void AddressList2::Login()
{
    string username;
    string password;

    AddressList1 add;
    cout<<"-----------欢迎使用本系统--------------"<<endl;
    cout<<"请输入您的用户名:";
    cin>>username;
    cout<<"请输入您的密码:";
    cin>>password;
    if(username=="Scott"&&password=="Hello")
        add.Appearance();
    else
    {
        do{
        cout<<"您输入的用户名或者密码不正确,请重新输入:"<<endl;
        cout<<"请输入您的用户名:";
        cin>>username;
        cout<<"请输入您的密码:";
        cin>>password;
            if(username=="Scott"&&password=="Hello")
            {
            add.Appearance();
            break;
            }
        }while(username=="Scott"&&password=="Hello");
    }
 
}
//主函数Add_Main.cpp
#include <iostream>
#include <string>
#include "AddressList.h"
using namespace std;
int main(void)
{

    AddressList add;
    AddressList2 add2;
    add2.Login();
    return 0;
}