‘’’
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
class Nguoi{
protected:
char hoTen[50];
int namSinh;
private:
char soThich[50];
public:
Nguoi(char ten[], int ns, char s[]){
strcpy(hoTen, ten);
namSinh = ns;
strcpy(soThich, s);
}
void Init();
};
class HocSinh : public Nguoi{
protected:
int msHS;
public:
void Init();
void Nhap();
};
void Nguoi::Init(){
cout << namSinh << endl;
cout << hoTen << endl;
cout << soThich << endl;
}
void HocSinh::Init(){
cout << msHS << endl;
cout << namSinh << endl;
cout << hoTen << endl;
}
void HocSinh::Nhap(){
cout << "Nhap ho ten: ";
gets(hoTen);
cout << "Nhap nam sinh: ";
cin >> namSinh;
}
int main(){
Nguoi people("Phan Thanh Nam", 1996, "code and game");
people.Init();
HocSinh student;
student.Nhap();
student.Init();
system("pause");
return 0;
}
‘’’
nó báo rằng no appropriate defauult constructor available… em không hiểu tại sao? lẽ nào em hàm khởi tạo của class Nguoi em làm sai ??
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?