作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
所以我有 2 个类,即 book
和 mainscreen
,其中 book
是从 mainscreen
公开继承的。
现在想通过mainscreen的成员函数使用class book的public成员函数。
这是我的代码:
class book;
class mainscreen:virtual public book
{
protected:
int logged;
public:
void printmenu();
void printhead();
void auth();
void logout();
mainscreen();
};
class book:public mainscreen
{
private:
int bookno,
days,
late_days;
long double price;
float fine_calc(int a,float b) // a -> late days , b -> fine per day
{
return a*b;
}
public:
book(); //const
void input();
void display();
void update();
};
调用部分:-
void mainscreen::printmenu(){
int i;
printhead();
cout<<"\n\n\t Choose a Number to perform the corresponding task \n";
cout<<"\n1.Enter a new Book ";
cout<<"\n2.Issue a Book ";
cout<<"\n3.Return a book" ;
cout<<"\n4.Update Information for a book ";
cout<<"\n5.Information About books ";
cout<<"\n6.Logout ";
cout<<"\nEnter your choice: ";
cin>>i;
menuhandler(i);
}
void mainscreen::menuhandler(int choice){ //the no of choice selected
switch(choice)
{
case 1: printhead();
input();
case 2: printhead();
issuebook();
case 3: printhead();
returnbook();
case 4: printhead();
update();
case 5: printhead();
display();
case 6: logout();
default:
cout<<"Invalid Choice! Press Return to Try again. ";
getch();
printmenu(); // Reset to menu
}
}
当我尝试在 mainscreen
的成员函数中使用类 book
的公共(public)成员函数时,出现以下错误:调用未定义的函数.
我是一名优秀的程序员,十分优秀!