Message 1 of 6
class-problem
Not applicable
03-06-2002
09:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello,
I created a simple class "Test", with 2 member variables: an integer and
a double. When I want to get the information back from a class member,
the double value always turns out to be 0.
Does anyone know what I do wrong??
(when I do the same in a simple c++ program, it works fine...)
class Test
{
public:
Test() { iVal = 0; \
dVal = 0; }
Test(int newI, double newD) { iVal = newI; \
dVal = newD; }
~Test() {}
void setiVal (int newI) { iVal = newI; }
void setdVal (double newD) { dVal = newD; }
int getiVal () { return iVal; }
double getdVal () { return dVal; }
private:
int iVal;
double dVal;
};
void CreateAndReadTest()
{
Test NewTest(5, 5.8);
acutPrintf("\n *** New Test Parameters ***");
acutPrintf("\n - integer value: %i", ActiveTest.getiVal());
// gives the correct info
acutPrintf("\n - double value: %d", ActiveTest.getdVal());
// always gives zero...
return;
}
--
hold your light, Eleven
I created a simple class "Test", with 2 member variables: an integer and
a double. When I want to get the information back from a class member,
the double value always turns out to be 0.
Does anyone know what I do wrong??
(when I do the same in a simple c++ program, it works fine...)
class Test
{
public:
Test() { iVal = 0; \
dVal = 0; }
Test(int newI, double newD) { iVal = newI; \
dVal = newD; }
~Test() {}
void setiVal (int newI) { iVal = newI; }
void setdVal (double newD) { dVal = newD; }
int getiVal () { return iVal; }
double getdVal () { return dVal; }
private:
int iVal;
double dVal;
};
void CreateAndReadTest()
{
Test NewTest(5, 5.8);
acutPrintf("\n *** New Test Parameters ***");
acutPrintf("\n - integer value: %i", ActiveTest.getiVal());
// gives the correct info
acutPrintf("\n - double value: %d", ActiveTest.getdVal());
// always gives zero...
return;
}
--
hold your light, Eleven