Errors with ->*
Shriramana Sharma <[email protected]> Tue, 02 Aug 2011 22:01:02 +0530
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
Hello -- long time since I posted on this list. I'm trying to understand the use of ->* but in compiling the attached program which I thought was straightforward I am getting the following errors: foo.cpp: In constructor ‘mystruct::mystruct()’: foo.cpp:9:12: error: invalid conversion from ‘int*’ to ‘int’ foo.cpp: In function ‘int main()’: foo.cpp:21:7: error: ‘xptr’ was not declared in this scope foo.cpp:22:7: error: ‘yptr’ was not declared in this scope Please help. -- Shriramana Sharma
foo.cpp
(text/x-c++src, 284 B)
struct mystruct
{
public:
int x, y ;
int * xptr, yptr ;
mystruct ()
{
xptr = & x ;
yptr = & y ;
}
} ;
int main ( void )
{
mystruct a ;
mystruct * aptr = & a ;
a . x = 1 ;
a . y = 2 ;
a .* xptr = 3 ;
a .* yptr = 4 ;
aptr ->* xptr = 5 ;
aptr ->* yptr = 6 ;
}