//make the snapshot() available to overload in this derived class
using abstract_data_unit::snapshot;
//return A string containing the fields to display.
//The string is encoded as a pickled Python dictionary.
virtual std::string snapshot(uint16_t *decoded_lcw) const;
and the errors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ldu1.cc: In member function 'virtual std::string ldu1::snapshot(uint16_t*) const':
ldu1.cc:163:21: error: expected primary-expression before '*' token
ldu1.cc:165:38: error: expected primary-expression before '*' token
ldu1.cc:166:36: error: expected primary-expression before '*' token
ldu1.cc:167:38: error: expected primary-expression before '*' token
ldu1.cc:168:38: error: expected primary-expression before '*' token
ldu1.cc:169:42: error: expected primary-expression before '*' token
ldu1.cc:172:26: error: expected primary-expression before '*' token
ldu1.cc:174:38: error: expected primary-expression before '*' token
ldu1.cc:175:36: error: expected primary-expression before '*' token
ldu1.cc:176:38: error: expected primary-expression before '*' token
ldu1.cc:177:45: error: expected primary-expression before '*' token
ldu1.cc:178:42: error: expected primary-expression before '*' token
ldu1.cc:181:1: warning: control reaches end of non-void function [-Wreturn-type]
Thanks! yes i am trying to call these functions. but when i take out the pointer syntax i get:
1 2 3 4
ldu1.cc: In member function 'virtual std::string ldu1::snapshot(uint16_t*) const':
ldu1.cc:163:23: error: passing 'const ldu1' as 'this' argument of 'virtual uint16_t ldu1::lcf(uint16_t*)' discards qualifiers [-fpermissive]
ldu1.cc:172:28: error: passing 'const ldu1' as 'this' argument of 'virtual uint16_t ldu1::lcf(uint16_t*)' discards qualifiers [-fpermissive]
ldu1.cc:181:1: warning: control reaches end of non-void function [-Wreturn-type]
error: passing 'const ldu1' as 'this' argument of 'virtual uint16_t ldu1::lcf(uint16_t*)' discards qualifiers
This error is because you have a const member function (snapshot) calling a non-const member function (lcf). This breaks const-correctness.
If lcf does not modify the object's state... then make it a const function.
Or if it does modify the state, you cannot call it from a const function... and you will have to change 'snapshot' to be non-const.
warning: control reaches end of non-void function
This is exactly what it says. You have a function that needs to return a value, but you do not end with a return statement.
std::string yourfunction()
{
if(...)
{ }
elseif (...)
{ }
else // else, return an empty string
return"";
}
// Or... just do this....
std::string yourfunction()
{
if(...)
{ }
elseif (...)
{ }
return""; // just return the empty string at the end of the function
}