Reputation: 69
class Button {
public:
Button(int pin, int debounce)
{
}
};
class TransferTable {
private:
Button a(1, 1);
public:
TransferTable()
{
}
};
The above code gives me an error of "expected identifier before numeric constant" in reference to the "Button a(1,1)" line. The type is Button. I just want to construct a button object within this TransferTable class.
Upvotes: 1
Views: 110
Reputation: 238291
The default member initializer syntax requires the use of curly braces:
private:
Button a{1,1};
Or, you can use the "equal-syntax" to do the same thing, as pointed out by juanchopanza:
private:
Button a = Button(1, 2);
Or, if you cannot rely on C++11, you must use the member initialization list instead.
Upvotes: 4
Reputation: 138
class Button
{
public:
Button(int pin, int debounce)
{
}
};
class TransferTable
{
public:
TransferTable() : a(1, 1)
{
}
private:
Button a;
};
Upvotes: 1