Hello,
working with classes, I am having problems parsing constructor arguments to object I create. Specifically, I am using the class found here:
http://www.codeproject.com/KB/cpp/MovingAverages.aspx. It creates objects that I can pass values to, then returns the moving average of those values.
After declaring an object in my .h file, using the standard constructor, so without parsing arguments, the object works like it should. However, I wish to use custom number of values to calculate average from. In the .h file, declaring an object like below gives errors.
CWeightedMovingAverage averager(5);
Errors:
1 2 3
|
src/testApp.h|76|error: expected identifier before numeric constant|
src/testApp.h|76|error: expected ‘,’ or ‘...’ before numeric constant|
||=== Build finished: 2 errors, 0 warnings ===|
|
Putting this code in .cpp file works, but it means I cannot use the object, because it will only exist temporarily in one specific method of the main testApp class which is called by main(). I am using openframeworks. The testApp object has methods like update() and draw() that get called sequentially all the time.
How can I parse the constructor argument outside of .h file, after declaring the object? Or, is there another way to construct this object, in .h file? Or should I revise the code so I can have a init() method or so?