các bạn xem giúp mk với ạ. mk tìm mãi mà vẫn k biết lỗi ở đâu . mình console thì nó chỉ hiển thị kết quả nhập mã cơ quan thì không chay tiếp
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#include<iostream>
class CMT
{
char*scmt,*ht;
int ns;
public:
CMT();
CMT(char * scmt1, char*ht1, int ns1);
~CMT();
CMT(CMT&);
const CMT & operator =(const CMT&);
friend istream & operator>> (istream &is, CMT&);
friend ostream& operator<<(ostream&os,CMT&);
CMT*laydc()
{
return this;};
};
CMT::CMT()
{
scmt= new char[12];
ht= new char[25];
ns=0;}
CMT::CMT(char* scmt1, char*ht1, int ns1)
{
scmt=new char[12]; strcpy(scmt,scmt1);
ht=new char[25]; strcpy(ht,ht1);
ns=ns1;
};
CMT::~CMT()
{
delete scmt;
delete ht;
ns=0;
};
const CMT&CMT::operator=(const CMT&h1)
{
strcpy(scmt, h1.scmt);
strcpy(ht, h1.ht);
ns=h1.ns;
return h1;
};;
CMT::CMT(CMT &h1)
{
scmt= new char[12];
strcpy(scmt,h1.scmt);
ht=new char[25];
strcpy(ht,h1.ht);
ns=h1.ns;
};
istream & operator>>(istream &is, CMT&h1)
{
cout<<"\nso cmt:"; cin.ignore(1);gets(h1.scmt);
cout<<"\n ho ten:"; gets(h1.ht);
cout<<"\n nam sinh:"; cin>>h1.ns;
return is;
}
ostream & operator<<(ostream &os, CMT&h1)
{
cout<<"\nso cmt:"<<h1.scmt;
cout<<"\n ho ten:"<< h1.ht;
cout<<"\n nam sinh:"<<h1.ns;
return os;
}
class CC: public CMT{
char *macq;
int nbc;
float ml;
public:
CC();
CC(char *scmt1, char*ht1, int ns1, char*macq1,int nbc1,float ml1);
~CC();
CC(CC&);
const CC & operator=(CC&);
friend istream & operator>> (istream &is, CC&);
friend ostream & operator<<(ostream&os,CC&);
float laytn()
{
return ml*1800000+1000000;
};
};
CC::CC():CMT()
{
macq:new char[12];
nbc=0;
ml=0.0;
};
CC::CC(char *scmt1,char *ht1,int ns1, char*macq1, int nbc1, float ml1):CMT(scmt1,ht1,ns1)
{
macq=new char [12];
strcpy(macq,macq1);
nbc=nbc1;
ml=ml1;
};
CC::~CC()
{
delete macq;
nbc=0;
ml=0;
}
const CC & CC:: operator=(CC&h1)
{
CMT *d1,*d2;
d1=(*this).laydc();
d2=h1.laydc();
*d1=*d2;
strcpy(macq,h1.macq);
nbc=h1.nbc;
ml=h1.ml;
return h1;
};
CC::CC(CC&h1)
{
*this=h1;;
};
istream &operator>>(istream&is,CC&h1)
{
CMT *dt1;
dt1=h1.laydc();
cin>>*dt1;
cout<<"\n ma cquan:"; cin.ignore(1);gets(h1.macq);
cout<<"\nnam bien che:";cin>>h1.nbc;
cout<<"\n muc luong:";cin>>h1.ml;
return is;
}
ostream&operator<<(ostream&os,CC&h1)
{
CMT*dt1;
dt1=h1.laydc();
cout<<*dt1;
cout<<"\n ma cquan:"<<h1.macq;
cout<<"\nnam bien che:"<<h1.nbc;
cout<<"\n muc luong:"<<h1.ml;
cout<<"\nthu nhap:"<<setprecision(10)<<h1.ml*1800000+1000000;
return os;
}
void nhap(CC s[], int n)
{
for(int i=0;i<n;i++)
{
cout<<"cong chuc ["<<i+1<<"]";
cin>>s[i];
}
};
float tbcc(CC s[], int n)
{
float tb=0;
for(int i=1;i<n;i++)
tb=tb+s[i].laytn();
return tb/n;
}
void swap (CC &p1, CC&p2)
{
CC temp;
temp=p1;p1=p2;p2=temp;
}
void sortcc(CC s[], int n)
{
int i,j;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(s[j].laytn()>s[i].laytn())
swap (s[i],s[j]);
};
void incc(CC s[], int n)
{
for(int i=0;i<n;i++)
cout<<"\n"<<s[i];
}
int main()
{
CC cc1[50];
int k;
cout<<"\n phan mem";
cout<<"\n so cong chuc la:";cin>>k;
cout<<"\n\n nhap cac cong chuc:";
nhap(cc1,k);
cout<<"\nthu nhap trung binh la:";
float c1;
c1=tbcc(cc1,k);
cout<<c1;
getch();
cout<<"\n danh sach cong chưc giam dan"<<endl;
sortcc(cc1,k);
incc(cc1,k);
getch();
}