Здравствуйте, в университете мы работаем bc 3.1 когда там написал данную программу она естественно не запустилась, не подскажите есть ли альтернатива функции typeid в 3.1 ?
/
#include <iostream.h>
#include <conio.h>
#include<string.h>
#include<stdlib.h>
#include<fstream.h>
#include<typeinfo.h>
enum etype {tmanager,tscientist,tlaborer};
const int LEN =32;
const int MAX=100;
class person
{
private:
char name[LEN];
long sarpl;
static int n;
static person* arrap[];
public:
static void add();
static void write();
static void read();
static void display();
virtual etype get_type();
virtual void vvod()
{
cout<<"\nwwedite imia ";
cin>>name;
cout<<"nwwedite sarabotnuyu platu ";
cin>>sarpl;
}
virtual void vivod()
{
cout<<"\nimia "<<name;
cout<<"\nsarplata "<<sarpl;
}
};
int person:: n=0;
person* person:: arrap[MAX];
class manager:public person
{
private:
char title[LEN];
double dues;
public:
void vvod()
{
person::vvod();
cout<<"wwedite dolgnost menegera ";
cin>>title;
cout<<"wwedite wsnosi w golf club ";
cin>>dues;
}
void vivod()
{
person::vivod();
cout<<"\ndolgnost "<<title;
cout<<"\nwsnosi w golf club "<<dues;
}
};
class scientist:public person
{
private:
int pubs;
public:
void vvod()
{
person::vvod();
cout<<"wwedite colichestwo publikaciy ";
cin>>pubs;
}
void vivod()
{
person::vivod();
cout<<"\ncolichestwo publicaciy "<<pubs;
}
};
class laborer:public person
{};
etype person::get_type()
{
if(typeid(*this)==typeid(manager))
return tmanager;
else if (typeid(*this)==typeid(scientist))
return tscientist;
else if(typeid(*this)==typeid(laborer))
return tlaborer;
else cout<<"\nneprawilniy tip rabotnika ";
}
void person::add()
{
char ch;
cout<<"m-menedger,s-ucheniy,l-laborant ";
cin>>ch;
switch(ch)
{
case 'm':arrap[n]=new manager;break;
case 's':arrap[n]=new scientist;break;
case 'l':arrap[n]=new laborer;break;
default:cout<<"\nneiswestniy tip ";
}
arrap[n++]->vvod();
}
void person::write()
{
int size;
cout<<"\nidet sapis";
etype type;
ofstream outfile;
outfile.open("d:\person.dat",ios::trunc|ios::binary);
if(!outfile)
cout<<"newosmogno otkrit fail ";
for(int j=0;j<n;j++)
{
type=arrap[j]->get_type();
switch(type)
{
case tmanager:size=sizeof(manager);break;
case tscientist:size=sizeof(scientist);break;
case tlaborer:size=sizeof(laborer);break;
}
outfile.write((char*)(&type),sizeof(type));
outfile.write((char*)(arrap[n]),size);
}
if(!outfile)
{
cout<<"\nsapis newosmogna ";
return;
}
}
void person::read()
{
int size;
etype type;
ifstream infile;
infile.open("d:\person.dat",ios::binary);
if(!infile)
{
cout<<"\nnewosmogno otkrit fail";
return;
}
n=0;
while(!0)
{
infile.read((char*)(&type),sizeof(type));
if(infile.eof())
break;
if(!infile)
{
cout<<"newosmogno prochitat naswanie tipa ";
return;
}
switch(type)
{
case tmanager:arrap[n]=new manager;size=sizeof(manager);break;
case tscientist:arrap[n]=new scientist; size=sizeof(scientist);break;
case tlaborer:arrap[n]=new laborer; size=sizeof(laborer);break;
default:cout<<"\nneiswestniy tip ";return;
}
infile.read((char*)(arrap[n]),size);
n++;
}
cout<<"\nidet chtenie rabotnika ";
}
void person::display()
{
etype type;
for(int j=0;j<n;j++)
{
cout<<(j+1);
sitch(arrap[n]->gettype())
{
case tmanager:cout<<" manager\n ";break;
case tscientist:cout<<" scientist\n ";break;
case tlaborer:cout<<" laborer\n ";
default:cout<<"\nneiswestniy tip ";return;
}
arrap[j]->vivod();
}
}
void main()
{
clrscr();
char ch;
while(!0)
{
cout<<"'a'-dobawit swedeniya o rabotnike\n 'w'-sapisat swedeniya o rabotnike w faiil\n'r'-prochitat is faila\n'd'-wiwesti wse swedeniya is faila\n'x'-wixod ";
switch(ch)
{
case 'a':person::add();break;
case 'd':person::display();break;
case 'w':person::write();break;
case 'r':person::read();break;
case'x':exit(0);break;
default:cout<<"\nneprawilniy wwod dannich ";
}
}
}