[英]c++: Pass pointer to object within object as argument
The code is for Arduino if that matters...如果这很重要,代码适用于 Arduino...
class Xbee{
public:
Xbee(SoftwareSerial *xbeeSerial, SoftwareSerial *debugPrinter);
};
class localXbee : public Xbee{
public:
localXbee(SoftwareSerial *xbeeSerial, SoftwareSerial *debugPrinter);
void addRemoteXbee(remoteXbee *newBee, byte index);
};
class remoteXbee : public Xbee{
public:
remoteXbee(long AddressLSB, SoftwareSerial *xbeeSerial, SoftwareSerial *debugPrinter);
class xbeeThermostat{
public:
xbeeThermostat(long AddressLSB, SoftwareSerial *xbeeSerial, SoftwareSerial *debugPrinter);
remoteXbee thermoBee;
};
So how do I call the addRemoteXbee function in the localXbee object when the remoteXbee object is inside the xbeeThermostat object?那么当remoteXbee对象在xbeeThermostat对象内部时,如何调用localXbee对象中的addRemoteXbee函数呢?
localXbee coordinator(&xbeeSerial, &debugPrinter);
xbeeThermostat thermostat(0x40BE4864, &xbeeSerial, &debugPrinter);
void setup(){
coordinator.addRemoteXbee(&xbeeThermostat.thermoBee,0);
}
When trying to compile I get the error message: expected primary-expression before '.'尝试编译时,我收到错误消息:“.”之前的预期主表达式。 token令牌
Found the obvious bug:发现明显的bug:
void setup(){
coordinator.addRemoteXbee(&thermostat.thermoBee,0);
}
Thanks for the help guys :)谢谢你们的帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.