Inner Class Data From Outside

Hi,

I have more or less the following structure;


Class A {

...

class B;
friend class B;

...

Class B

{
public:
QString getS();
void setS(const QString&);

private:
QString s;

}

friend class B;

}


I've implemented getS in the cpp of Class A like

// A.cpp
QString A::B::getS()
{

}

void A::B::setS(const QString p_s)
{
s = p_s
}


The problem I experienced is; when I attempt to call setS from another class let's say Class C, I get a runtime error saying that in the assignment of s = p_s...Saying s is never created.

Any ideas?


Show how you instantiate class B from class C, and then show how you call setS().
I create B in class A's constructor.

I call setS from different from class C like;

a->getClassB()->setS("asdsa");

But it seems like it didn't create it properly. I debugged the code and saw it's created. But somehow it's erased I suppose. What say you?

Show the definition of A::getClassB().
Topic archived. No new replies allowed.