本文介绍了请调试我的程序错误(多重继承)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是多重继承的一个例子
#include < iostream.h > #include < conio.h > 课程员工 { 私有: 字符 emp_name [ 25 ],eaddress [ 25 ],ecity [ 15 ],estate [ 2 ]; double esalary; 公共: void emp_input( void ); void emp_print( void ); }; class 客户 { 私有: 字符客户名称[ 25 ],地址[ 25 ],city [ 25 ],state [ 25 ]; 双余额; void cust_input( void ); void cust_print( void ); }; class emp_cust: public 员工, public 客户 { 公共: void get_data( void ); void show_data( void ); }; 无效 emp_cust :: get_data( void ) { 无效 emp_input(); 无效 cust_input(); } 无效 emp_cust :: show_data() { 无效 emp_print(); 无效 cust_print(); } 无效 employee :: emp_print() { cout<< " \ n员工名称" << emp_name; cout<< " \ n地址" << eaddress; cout<< " \ nCity" << ecity; cout<< " \ nState" << ;; cout<< " \ nSalary" << esalary; } 无效 customer :: cust_print( void ) { cout<< " \ n \ n客户名称" << cust_name; cout<< " \ n地址" << ;; cout<< " \ nCity" << city; cout<< " \ nstate" << state; cout<< " \ nBalance" << } void employee :: emp_input( void ) { cout<< " 输入员工姓名" ; cin>> emp_name; cout<< " 输入员工地址" ; cin> eaddress; cout<< " 输入城市" ; cin> ecity; cout<< " 输入状态" ; cin> estate; cout<< " 输入薪水" ; cin> esalary; } 无效 customer :: cust_input( void ) { cout<< " 输入客户名称" ; cin>> cust_name; cout<< " 输入客户地址" ; cin>>地址; cout<< " 输入城市" ; cin> city; cout<< " 输入状态" ; cin>状态; cout<< " 平衡" ; cin>平衡; } 无效 main() { clrscr(); emp_cust empcust; empcust.get_data(); empcust.show_data(); getch(); }
但是该程序已执行但emp_input()
无效void cust_input()void emp_print()
无效cust_print()是否由工作人员y执行?请帮我
谢谢您
解决方案
this is an example of multiple inheritance
#include<iostream.h> #include<conio.h> class employee { private: char emp_name[25],eaddress[25],ecity[15],estate[2]; double esalary; public: void emp_input(void); void emp_print(void); }; class customer { private: char cust_name[25],address[25],city[25],state[25]; double balance; void cust_input(void); void cust_print(void); }; class emp_cust:public employee,public customer { public: void get_data(void); void show_data(void); }; void emp_cust::get_data(void) { void emp_input(); void cust_input(); } void emp_cust::show_data() { void emp_print(); void cust_print(); } void employee::emp_print() { cout<<"\nEmployee name" <<emp_name; cout<<"\nAddress"<<eaddress; cout<<"\nCity"<<ecity; cout<<"\nState"<<estate; cout<<"\nSalary"<<esalary; } void customer::cust_print(void) { cout<<"\n\nCustomer name"<<cust_name; cout<<"\nAddress"<<address; cout<<"\nCity"<<city; cout<<"\nstate"<<state; cout<<"\nBalance"<<balance; } void employee::emp_input(void) { cout<<"Enter theEmployee name"; cin>>emp_name; cout<<"Enter the employee address"; cin>>eaddress; cout<<"Enter city"; cin>>ecity; cout<<"Enter state"; cin>>estate; cout<<"Enter salary"; cin>>esalary; } void customer::cust_input(void) { cout<<"Enter custmor name"; cin>>cust_name; cout<<"Enter costomer address"; cin>>address; cout<<"Enter city"; cin>>city; cout<<"Enter state"; cin>>state; cout<<"Balance"; cin>>balance; } void main() { clrscr(); emp_cust empcust; empcust.get_data(); empcust.show_data(); getch(); }
but this program is executed but void emp_input()
void cust_input()void emp_print()
void cust_print() are not executed by empcust y? plz help me out
THANK YOU
解决方案
这篇关于请调试我的程序错误(多重继承)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!