D
dr_tella_nu
Hello World,
the following code throws this error:
error c2039: 'z' : is not a member of 'a'
#include <iostream>
using namespace std;
void main(void)
{
struct a
{
float x, y;
a *next;
};
struct b : public a
{
float z;
};
b* frame1 = new b();
b* frame2 = new b();
frame1->next = frame2;
frame1->z = 3.0;
frame2->z = 5.0;
b* test = (b*)frame1->next;
float c = test->z;
cout << c << endl;
float d = (b*)frame1->next->z; // error
cout << d << endl;
}
furthermore i am not understanding the need of casting
(b*)frame1->next.
please help
Thanks ahead!
the following code throws this error:
error c2039: 'z' : is not a member of 'a'
#include <iostream>
using namespace std;
void main(void)
{
struct a
{
float x, y;
a *next;
};
struct b : public a
{
float z;
};
b* frame1 = new b();
b* frame2 = new b();
frame1->next = frame2;
frame1->z = 3.0;
frame2->z = 5.0;
b* test = (b*)frame1->next;
float c = test->z;
cout << c << endl;
float d = (b*)frame1->next->z; // error
cout << d << endl;
}
furthermore i am not understanding the need of casting
(b*)frame1->next.
please help
Thanks ahead!