a must-non constant alias argument with its default argument must be constant
Jan 16, 2020 at 3:20am UTC
How do we code a must-non constant alias argument with its default argument must be constant as it's being non referenced ?
as this fail
1 2 3 4 5 6 7 8 9 10 11
Bar {
int on;
Bar(){};
Bar(bool o): off{o}{}
bool off;
}
int fooBar(int board, Bar& bar = static_cast <Bar>(1)) {
//...
}
gcc show:
error: cannot bind non-const lvalue reference of type 'Bjavascript:editbox1.editSend()ar&' to an rvalue of type 'Bar'
How to solve
Last edited on Jan 16, 2020 at 4:05am UTC
Jan 16, 2020 at 6:00am UTC
If you're trying to declare a struc you need the prefix struct in front of Bar.
And to define your function fooBar you would also need to add Bar::
int Bar::fooBar(int board, Bar& bar = static_cast <Bar>(1)) {}
Topic archived. No new replies allowed.