Well, I think figured out why it didnt work. It was rather confusing to see something instantiated with the name State(const char*) which wasnt defined in State.h and not in the State class itself.
I looked at the example code you pointed me at and there is only one line that is comparable to my case (State must be interpreted in a number context):
Code: Select all
mpTarget->Top = mpTarget->Height * ( State( "TargetCode" ) - 1 );
Since the State class itself doesnt implement any casting operator or - operator, I assume that this State(...) expression gets interpreted as
Code: Select all
double Expression::State( const char* inName )
.
At least this would explain why my int val = State("blabla") didnt work, because there is no method which return an int so the the term can not be evaluated.
Still the question for me remains, if I instantiate a State object (which obviously has a Value() method) why is it made private? Write access is public though, doesnt make sense to me.
This is what i mean (non-relevant lines removed):
Code: Select all
class State
{
friend class StateVector; // calls SetLocation(), GetValue(), Commit()
friend class StateList; // calls GetValue()
friend class CoreModule; // calls GetValue()
public:
typedef unsigned long ValueType;
public:
State();
~State() {}
State& AssignValue( const State& s )
{ return SetValue( s.Value() ); }
State& SetValue( ValueType );
private:
ValueType Value() const
{ return mValue; }
...
};
My lack of deeper understanding of your code structure makes it still difficult to understand why this "magical" interpretation occurs. So bear with me if i ask stupid questions
Alex