![]() |
C++ NetworkTable code error
I'm getting an error in my code
Code:
cannot convert 'std::shared_ptr<NetworkTable>' to 'NetworkTable*' in assignmentCode:
table = NetworkTable::GetTable("datatable"); |
Re: C++ NetworkTable code error
Hey!
The getTable method returns a shared pointer. So you have to declare your table as a shared pointer by writing: std::shared_ptr<NetworkTable> table = NetworkTable::GetTable("datatable"); That should fix that issue! That tutorial is from 2014 and WPILib has been updated and is now in C++11 which introduced Smart Pointers. I would suggest taking a look at the library :Here! |
Re: C++ NetworkTable code error
(That link should be this instead - missing a colon.)
Basically, the error means that the type of your table variable is "NetworkTable*" (a pointer to a NetworkTable), while GetTable() returns a std::shared_ptr<NetworkTable>, which can't be converted to a NetworkTable* directly. The place you actually want to change is currently line 9 in your code, where you declare "table" - it should be "std::shared_ptr<NetworkTable> table;". |
Re: C++ NetworkTable code error
The things posted above are the proper solution. I'll contact the Screensteps people to get it updated.
|
| All times are GMT -5. The time now is 10:15. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi