seekinganswer
December 5th, 2002, 07:00 PM
** confused **
// example.h
class example
{
public:
inline const int getValue()
{
return theeAnswer;
}
private:
int theeAnswer;
void function();
}
//example.cpp
void example::function()
{
theeAnswer = 5;
cout << getValue(); // its 5 like it should be
}
// another_file.cpp
#include "example.h"
void function()
{
example eo;
int retval = eo.getValue();
cout << retval; // its NOT 5 like it should be
retval comes back as other numbers, mostly large but never as 5. Its very much acting like an uninitialized variable, but I don't see how this can be.
Anyone have an idea?
Thanks,
// example.h
class example
{
public:
inline const int getValue()
{
return theeAnswer;
}
private:
int theeAnswer;
void function();
}
//example.cpp
void example::function()
{
theeAnswer = 5;
cout << getValue(); // its 5 like it should be
}
// another_file.cpp
#include "example.h"
void function()
{
example eo;
int retval = eo.getValue();
cout << retval; // its NOT 5 like it should be
retval comes back as other numbers, mostly large but never as 5. Its very much acting like an uninitialized variable, but I don't see how this can be.
Anyone have an idea?
Thanks,