I\'m working through Bjarne Stroustrup\'s The C++ Programming Language and I\'m stuck on one of the examples. Here\'s the code, and aside from whitespace differences and comment
You have a couple of problems:
First, you are attempting to implement a function (operator++
) inside another function (main
). C++ does not allow this (with the exception of lambdas).
Second, you are only implementing a prefix increment, so ++light
will work, but light++
will not. You should implement them both. An example of it can be found here.