T
trying_to_learn
im trying to index through an array that is member of a class using ptr
to member
in main i tried making a ptr to the member 'arr' :
const int * testclass7::* ptrToMemberIntPtr = &testclass7::arr;
------------------------------------------------------
the compiler cries:
cannot convert from 'int (testclass7::*)[10]' to 'const int *testclass7::* '
Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast
------------------------------------------------------
I cant figure this out... isnt arr basically a const int * ?
how do i define a ptr to member arr?
class testclass7
{
public:
int arr[10];
testclass7(int arg=1)
{
for (int i=0;i<sizeof(arr) / sizeof(*arr);i++)
{
arr = arg+i;
}
}
};
to member
in main i tried making a ptr to the member 'arr' :
const int * testclass7::* ptrToMemberIntPtr = &testclass7::arr;
------------------------------------------------------
the compiler cries:
cannot convert from 'int (testclass7::*)[10]' to 'const int *testclass7::* '
Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast
------------------------------------------------------
I cant figure this out... isnt arr basically a const int * ?
how do i define a ptr to member arr?
class testclass7
{
public:
int arr[10];
testclass7(int arg=1)
{
for (int i=0;i<sizeof(arr) / sizeof(*arr);i++)
{
arr = arg+i;
}
}
};