J
Jeff
Hello-
1. I create a fully complete class (ListClass)
2. I pass the pointer of this class to two (or more) other classes.
3. I get a SEGV while accessing a member of the top level class
(ListClass)
Essentially the ListClass reads a file and fills its data fields.
After its initialization
I need to pass it to multiple other objects so that they have the data
which is
read only at this point (Im sure of this btw).
Code snippet:
ListClass *lc = new ListClass(filename);
classA a(lc);
classB b(lc); <====SEGV
classA(ListClass *list) :
m_val(list->getValue())
{
}
classB(ListClass *list) :
m_val(list->getValue()) <----real SEGV line
{
}
int
ListClass::getValue(int val) const
{
return m_value;
}
I had thought that I passed in a pointer to the ListClass class and
could
read anything I want without troubles. Can someone more experienced
please give me some feedback? I have a feeling something is getting
constructed instead of just passed, but IDK.
Thanks,
Jeff
1. I create a fully complete class (ListClass)
2. I pass the pointer of this class to two (or more) other classes.
3. I get a SEGV while accessing a member of the top level class
(ListClass)
Essentially the ListClass reads a file and fills its data fields.
After its initialization
I need to pass it to multiple other objects so that they have the data
which is
read only at this point (Im sure of this btw).
Code snippet:
ListClass *lc = new ListClass(filename);
classA a(lc);
classB b(lc); <====SEGV
classA(ListClass *list) :
m_val(list->getValue())
{
}
classB(ListClass *list) :
m_val(list->getValue()) <----real SEGV line
{
}
int
ListClass::getValue(int val) const
{
return m_value;
}
I had thought that I passed in a pointer to the ListClass class and
could
read anything I want without troubles. Can someone more experienced
please give me some feedback? I have a feeling something is getting
constructed instead of just passed, but IDK.
Thanks,
Jeff