Are you looking for protected
?
Note: this is a supposition, as the question is not completely clear to me. If you want to access parent class properties, they need to be declared in a protected
or public
section.
Here is a sample:
#include <iostream>
class camerafunction
{
protected:
int systemEventHandler=0;
public:
void detectcam()
{
std::cout << "detectcam"<< std::endl;
};
};
class MFCGUI : public camerafunction
{
public:
void startdeviceevent()
{
systemEventHandler = 42;
std::cout << "startdeviceevent with systemEventHandler=" << systemEventHandler << std::endl;
}
};
class SystemEventHandlerImpl
{
public:
void onDeviceArrival()
{
MFCGUI obj;
obj.startdeviceevent();
obj.detectcam();
}
};
int main()
{
SystemEventHandlerImpl obj;
obj.onDeviceArrival();
return 0;
}
Run it online:
https://onlinegdb.com/r1NyfgelO
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…