I imagine the probem here is with your MetronomeGUI class. Step through your code with the debugger. That's what they are there for. And if you've never used one before, please take the time to learn. In the long run it will save your hours and hours of head scratching!
I am not sure if this changed in recent compiler languages, but when I learned C++ the return value of an assignment was "true". So in your case you add a "true" as a child, which will not work...
If you do this in two lines I *think* it should work:
metronomeGUI = new MetronomeGUI ();
addAndMakeVisible (metronomeGUI);
But there might be other problems, which you may find in your debugger, as Rory said...
when I learned C++ the return value of an assignment was "true"
Sorry but that's definitely not true. In C++, the assignment operator typically returns a reference to the object on the left hand side after assignment. Otherwise you couldn't chain assignments like this: a = b = c = d;
Of course, people can overload the assignment operator in their classes, and theoretically they could make it return whatever they want to, but C++ best practice is that you should always do the above.
I found what the problem was... scopped pointers are fine, I don't get why you suggest not using one when Jules says that using them is encouraged (or at least I think I read that somewhere)
I was calling Component::setSize in the first line of the class constructor, which from what I read in the documentation calls synchronously the Component::resized() method... in that method I had metronomeGUI->setBounds(0, 0, getWidth(), getHeight()); But the metronomeGUI variable was not yet initialized.... hence the seg fault.
This kind of issue is found with a debugger within seconds so as Rory already suggested, you should get to know how to debug.
In Visual Studio it is advisable to also break on exceptions (set “Win32 Exceptions” in Debug->Exceptions). You then see where in your program a crash occurs and can step backwards through the stack trace to corner the crash’s cause.
It’s easier to use objects instead of ScopedPointer<> as the object’s initialisation is also automatic. You only need to use a pointer if the object’s constructor relies on the holder’s this pointer as this isn’t necessarily valid within the initialisation list.
Yeah, visual studio... I'm on linux ... Of course I tried iwth a debugger but I don't know how to use them well yet in linux, I'm still figuring out my tools. In visual studio debugging is kids play, was doing that since visual studio 6... Thanks.
That's not really an excuse in this day and age Chris!! Linux has plenty of IDEs that let you step through your code. CodeLite, CodeBlocks, Eclipse, KDeveloper, NetBeans, Anjuata, etc. Ok, there are not as developed as VS, but CodeLite integrates its debugger very nicely, and was clearly influenced by MS tools.
[edit] I hope this doesn't come across as dismissive. I just wanted to point out, in friendly way, that things aren't so bad on Linux as some people think!