Arduino C++ - Error when trying to instantiate class which has non-type template parameter -
here's file in try instantiate "melodie" object:
#include <melodie.h> melodie<5> m(8); void setup() { } void loop() { } here's "melodie.h" file:
#ifndef melodie_h #define melodie_h #include <arduino.h> #include "pitches.h" template <int nb_notes> class melodie { public: melodie(int pin) { // unimportant stuff } void addnote(int pitch, int duration) { // unimportant stuff } void play() { // unimportant stuff } private: char notes_[nb_notes]; char durations_[nb_notes]; int notepointer_; int pin_; }; #endif i following error message: error: expected constructor, destructor, or type conversion before '<' token
why? same code works(minus arduino specific stuff) works in visual studio. thought winavr supported c++?
i tried , compiled code (gcc) without problem 2 minor modifications.
- change
#include <melodie.h>#include "melodie.h" comment out following
//#include <arduino.h> //#include "pitches.h"
since not used.
Comments
Post a Comment