|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
C++ NetworkTable code error
I'm getting an error in my code
Code:
cannot convert 'std::shared_ptr<NetworkTable>' to 'NetworkTable*' in assignment Code:
table = NetworkTable::GetTable("datatable");
|
|
#2
|
||||
|
||||
|
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! |
|
#3
|
|||
|
|||
|
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;". |
|
#4
|
||||
|
||||
|
Re: C++ NetworkTable code error
The things posted above are the proper solution. I'll contact the Screensteps people to get it updated.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|