0

I have some class, and in it I want to create object of another class ... Usually I do it in header file, I just put something like:

QString RSSName;

and it works because that class has constructor that has no parameters ...

So here's my problem: how do I do that for some class(let's say ErrorOutput) that has only constructor with 1 or more parameters? I don't want to create pointer to object, I need it to be something like this:

ErrorOutput err("test");

I hope I've described the question correctly, it's little sleepy over here :P

Thanks for help :)

xx77aBs
  • 4,678
  • 9
  • 53
  • 77

1 Answers1

3

It's a bit hard to tell from your description what exactly you are asking for, but it sounds like "RSSName" is a member variable in your class. If I'm correct about that, initialize it in the constructor's initialization list.

class Foo
{
public:
    Foo() : RSSName(someVal) { }

private:    
    QString RSSName;
}
Ed S.
  • 122,712
  • 22
  • 185
  • 265
  • Yeah, that's what I wanted ... The sad thing is that I knew about this, but just couldn't remember. It's time to go to sleep and continue tomorrow :) Thanks !! – xx77aBs Jan 27 '11 at 00:06