Hello,
I'm having trouble passing a class object that requires a single parameter for the constructor.
The result I want being, inside another class, pass the already initialized object's pointer to another variable.
eg.
//FirstClass Constructor
FirstClass::FirstClass(char* name)
{
// Start with file not open.
fOpen = false;
// Store the file name.
strcpy(fName, name);
}
//Create FirstClass
FirstClass * FC = new FirstClass("testfile.dat"
;
//Second Class Constructor
SecondClass::SecondClass(FirstClass* theFirst)
{
FirstClass * dupFirst = theFirst;
}
//Create SecondClass
SecondClass * SC = new SecondClass(FC);
It doesn't appear 'dupFirst' is getting assigned the values from 'theFirst'. Is it because of the missing constructor parameter from FirstClass?
Any help would be appreciated.
Brian
I'm having trouble passing a class object that requires a single parameter for the constructor.
The result I want being, inside another class, pass the already initialized object's pointer to another variable.
eg.
//FirstClass Constructor
FirstClass::FirstClass(char* name)
{
// Start with file not open.
fOpen = false;
// Store the file name.
strcpy(fName, name);
}
//Create FirstClass
FirstClass * FC = new FirstClass("testfile.dat"
//Second Class Constructor
SecondClass::SecondClass(FirstClass* theFirst)
{
FirstClass * dupFirst = theFirst;
}
//Create SecondClass
SecondClass * SC = new SecondClass(FC);
It doesn't appear 'dupFirst' is getting assigned the values from 'theFirst'. Is it because of the missing constructor parameter from FirstClass?
Any help would be appreciated.
Brian