xx77aBs
xx77aBs

Reputation: 4768

C++, object declaration in header files

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 :)

Upvotes: 0

Views: 2072

Answers (1)

Ed Swangren
Ed Swangren

Reputation: 124722

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;
}

Upvotes: 3

Related Questions