S
Squid Seven
I have created a class that contains an instance of a second class.
When i try to call a member function of the instance of the second class
from a member function of the containing class, I get the following
error message:
Insufficient contextual information to determine type.
I have generated the simplest sample I could come up with that
duplicates this error, and it is attached below. I am fairly new to
programming and hope that I am not wasting anyone's time with this, but
I have been searching the net and my reference texts for the past three
hours trying to figure it out and am completely frustrated. It must
have something to do with the second class being user defined, because
if I substitute a string object I have no problem manipulating it.
Please help!
Sample code:
#include <iostream>
using std::cout;
class FirstClass {
public:
FirstClass();
void setFirstClassValue( int );
private:
int firstClassValue;
};
FirstClass::FirstClass()
{
firstClassValue = 7;
}
void FirstClass::setFirstClassValue( int newValue )
{
firstClassValue = newValue;
}
class SecondClass {
public:
SecondClass();
private:
FirstClass instanceOfFirstClass();
};
SecondClass::SecondClass()
{
instanceOfFirstClass.setFirstClassValue( 10 ); //The problem line
};
main()
{
SecondClass instanceOfSecondClass();
Return 0;
}
When i try to call a member function of the instance of the second class
from a member function of the containing class, I get the following
error message:
Insufficient contextual information to determine type.
I have generated the simplest sample I could come up with that
duplicates this error, and it is attached below. I am fairly new to
programming and hope that I am not wasting anyone's time with this, but
I have been searching the net and my reference texts for the past three
hours trying to figure it out and am completely frustrated. It must
have something to do with the second class being user defined, because
if I substitute a string object I have no problem manipulating it.
Please help!
Sample code:
#include <iostream>
using std::cout;
class FirstClass {
public:
FirstClass();
void setFirstClassValue( int );
private:
int firstClassValue;
};
FirstClass::FirstClass()
{
firstClassValue = 7;
}
void FirstClass::setFirstClassValue( int newValue )
{
firstClassValue = newValue;
}
class SecondClass {
public:
SecondClass();
private:
FirstClass instanceOfFirstClass();
};
SecondClass::SecondClass()
{
instanceOfFirstClass.setFirstClassValue( 10 ); //The problem line
};
main()
{
SecondClass instanceOfSecondClass();
Return 0;
}