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 :)
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;
}
精彩评论