问题描述
头文件与其他头文件一起继承为。
--------------首先是头文件---------
The header file is inherited with other header files as.
--------------Header file first---------
#ifndef doing_h
#define doing_h
class doing{
public:
doing(int a){......}
fn_doing1(){.........}
}
#endif
---------- ----头文件第二---------
--------------Header file second---------
#ifndef something_h
#define something_h
class something{
public:
something(int a,int b){......}
fn_something1(){.........}
}
#endif
------------- -Main头文件---------
--------------Main header file---------
ifndef main_header_h
#define main_header_h
#include "doing.h"
#include "something.h"
class main_header : public doing, public something{
public:
main_header(){......}
fn_main_header1(){.........}
}
#endif
现在我想在代码中访问头文件的特定功能
Now in the code i want to access the specific function of the header files as
#include "main_header.h"
main_header DOING(2) //I want the DOING to call the first header constructor and should represent the first header file only
main_header SOMETHING(2,8) //I want the DOING to call the Second header constructor and should represent the first header file only
void main(){
DOING.fn_doing1(); //can be called
DOING.fn_something1() //cannot be called
}
如何制作DOING和SOMETHING分别调用第一个和第二个头文件函数。
请建议所有必要的更改和编辑。
请帮助我。
我尝试了什么:
我试过但不能这样做。
How can i make the DOING and SOMETHING call the first and second header file functions respectively.
Please suggest all the necessary changes and editing required.
Please help me.
What I have tried:
I have tried but not able to do so.
推荐答案
class doing : public something{
//...
};// end doing
class main_header : public doing
这篇关于我想创建一个包含以下结果的头文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!