-
objects
Something I am very confused about..assuming I had the class and functions found below.
When the printTestData() fnct starts running, will the listObj contain anything in it? or am I suppose to first return and the send the listObj via pass by reference to the printTestData() fnct?
Also...if I am suppose to send the listObj via pass by reference, then why am I declaring it within the class structure? Couldn't I just create it in the createTestList() function and then send it?
Code:
class Test
{
private:
SLList<Dictionary> listObj;
Dictionary dObj;
createTestList ();
printTestData();
.....
.....
};
//--------------------------------------------------
void Test::createTestList()
{
....
while (i++ < something)
{
....
....
listObj.makeLink(dObj);
}
}
//---------------------------------------------------
void Test::printTestData()
{
....
....
while (i++ < something)
{
dObj = listObj.printList(); <--Here
cout << dObj.data << endl;
}
}
//---------------------------------------------------
int main ()
{
Test x;
x. createTestList();
x.printTestData();
return 0;
}
thanx
-
There's too little source code to say.
-
This code is for sample purposes....normally if in a condition where a list, tree etc is created using a obj declared within the class, would the contents within that object cease to exist when the function using it has finnished with it? That is what I am after. I know it would not exist if the obj was declared within the function.
-
All your member variables of an instance will persist as long as the instance itself persists.
In other words, while "x" is valid, all members of "x" are valid.
gg