D
Don
I am a newbie to CPP so have patience......
I have the small code piece below, I want to pass the object1, declared in
the main function, to the testfunc2 function as a pointer, making the
tester[8] of Object1 becoming 0x1A.
Does anyone know how this would be done......
Don
class mytestclass
{
public:
mytestclass(); // constructor
void testfunc();
private:
unsigned char tester[10]; //holds a list of announcements only 0 to 4 are
used
unsigned int mytest;
};
mytestclass::mytestclass()
{
tester[0] = 0x11;
tester[1] = 0x22;
tester[2] = 0x33;
tester[3] = 0x44;
tester[4] = 0x55;
tester[5] = 0x66;
mytest = 0;
}
void mytestclass::testfunc()
{
tester[8] = 0x1A;
}
void testerfunc2(mytestclass* testobj){
testobj.testfunc();
}
int main(){
mytestclass object1;
testerfunc2(&object1);
//printing object1.tester[8] should yield the result 0x1A
return 0;
}
I have the small code piece below, I want to pass the object1, declared in
the main function, to the testfunc2 function as a pointer, making the
tester[8] of Object1 becoming 0x1A.
Does anyone know how this would be done......
Don
class mytestclass
{
public:
mytestclass(); // constructor
void testfunc();
private:
unsigned char tester[10]; //holds a list of announcements only 0 to 4 are
used
unsigned int mytest;
};
mytestclass::mytestclass()
{
tester[0] = 0x11;
tester[1] = 0x22;
tester[2] = 0x33;
tester[3] = 0x44;
tester[4] = 0x55;
tester[5] = 0x66;
mytest = 0;
}
void mytestclass::testfunc()
{
tester[8] = 0x1A;
}
void testerfunc2(mytestclass* testobj){
testobj.testfunc();
}
int main(){
mytestclass object1;
testerfunc2(&object1);
//printing object1.tester[8] should yield the result 0x1A
return 0;
}