DTH11 | DHT11 test project -
kandi X-RAY | DTH11 Summary
kandi X-RAY | DTH11 Summary
DTH11
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of DTH11
DTH11 Key Features
DTH11 Examples and Code Snippets
Community Discussions
Trending Discussions on DTH11
QUESTION
Currently I am in a project where I need to dynamically add and remove sensors to a hardware (Arduino).
In order to do that, I have created a base class named "Sensor" and derivated class for each sensor. This "sensor" class has a virtual method called execute, and this method in overriden on each derivated class, due that each sensor is different, so a different execution implemantation is needed for each type. In this example, I used PIR and DTH11 has derivated classes.
When a sensor needs to be added, the hardware will recieve a string from a server, and from this recieved string, it will create the appropriate sensor. In order to simplyfy things in this questions, I just did it manually on the main() method.
To store the sensors, I am using a std::list, and from time to time, the method execute() will be called.
However, the method of the base class (Sensor) is always executed instead of the delivered classes as shown on the results and expected results below.
...ANSWER
Answered 2018-Oct-30 at 15:28The issue is that you are returning a Sensor
by value. This creates a copy of your original sensors without the additional extended data (a.k.a. called as slicing).
Use:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DTH11
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page