Hey, in a tutorial C++ code, I found this particular piece of confusion:
PlasmaTutorial1::PlasmaTutorial1(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args), // <- Okay, Plasma = namespace, Applet = class
m_svg(this), // <- A member function of class "Applet"?
m_icon("document") // <- ditto?
{
m_svg.setImagePath("widgets/background");
// this will get us the standard applet background, for free!
setBackgroundHints(DefaultBackground);
resize(200, 200);
}
I'm not new to object oriented programming, so class derivation and super-classes are nothing complicated, but this syntax here got me confused.
The header file defines the class like this:
class PlasmaTutorial1 : public Plasma::Applet
{
Similar to above, namespace Plasma and class Applet. But what's the public doing there?
I fear that I already know the concept but don't grasp the C++ syntax/way of doing it.
In this question I picked up that these are called "superconstructors", at least that's what stuck in my memory, but I don't get this to the full extend.
If we glance back at the first snippet, we see Constructor::Class(...) : NS::SuperClass(...), all fine 'till here. But what are m_svg(this), m_icon("document") doing there? Is this some kind of method to make these particular functions known to the derivated class?
Is this part of C++ basics or more immediate? While I'm not completly lost in C++, I feel much more at home in C :)
Most of the OOP I have done so far was done in D, Ruby or Python. For example in D I would just define class MyClass : MySuperClass, override what I needed to and call the super class' constructor if I'd need to.