Value Tree Tutorial - ERROR

Dear All,

I’m trying to use the Value Tree class and started working with the Tutorial.
Right at the start I get stuck with a wrather weird bug.

By just copying / rewriting the two lines from the “valid value tree object” paragraph into my MainComponent.h:

static Identifier myNodeType(“MyNode”); ≤≤ "Expected ‘)’
ValueTree myNode (myNodeType);

Xcode outputs the Error "Expected ‘)’ for the Identifier constructor and then says myNodeType is unknown ( which makes sense when the Identifier construction doesn’t work).

Is there something else I’m missing?

Thanks for any tips or help!

When you declare members in the class declaration, you don’t call the constructor but supply default arguments in form of an initialiser list.
It should work if you use {} instead.

N.B. these default argument will be ignored, if the constructor of the member is called in the implementation.

Dear daniel,

thanks for the fast reply! I’m a beginner with c++ so this tip is worth gold :slight_smile: (maybe this could be added somewhere, for other “newbies” like me? Or maybe it is common knowledge I just never knew).

Moving the code into the constructor works fine!

Using the {} works in the declaration aswell, thank you! So my question is, where is the place this snippet from the tutorial is supposed to be? Maybe this context could be given in the tutorial for beginners like me to avoid this problem?

My thinking was “since I want this static thing to always be there, I define it right at the start in the declaration so I can use it everywhere then”.

Thanks again for your help, now I’m a bit wiser :slight_smile: