I
irvin.hwang
Hi,
I'm having a problem passing a pointer of a struct. Here is the code
that's giving me a trouble.
1. shape *s;
2. s = load_shape();
3. shape2grammar(s);
test.cpp:53: error: no matching function for call to
'shape2grammar(shape*&)'
This is the declaration of shape2grammar...it takes a pointer to shape
as an argument
prod_rule<T>* shape2grammar(shape* s)
Shape is a struct...
struct shape {
location *v;
int num;
matrix<bool> *edges; // adjencency matrix for triangulation
};
and load_shape() returns a pointer to a shape
shape *load_shape()
It appears the program thinks line '3. shape2grammar(s)' is a call
where s is a pointer to the address of a shape (when I tried replacing
this with '3. shape2grammar(*s)' i get the error "no matching function
for call to 'shape2grammar(shape&)'")
but it's clear that what is returned by '2.s = load_shape()' is a
pointer to a shape because I tried accessing the members of s before
the call '3. shape2grammar(s)' (i.e. 's->num' works) and it seemed
fine.
Any suggestions would be appreciated.
Thanks,
Irvin H.
I'm having a problem passing a pointer of a struct. Here is the code
that's giving me a trouble.
1. shape *s;
2. s = load_shape();
3. shape2grammar(s);
test.cpp:53: error: no matching function for call to
'shape2grammar(shape*&)'
This is the declaration of shape2grammar...it takes a pointer to shape
as an argument
prod_rule<T>* shape2grammar(shape* s)
Shape is a struct...
struct shape {
location *v;
int num;
matrix<bool> *edges; // adjencency matrix for triangulation
};
and load_shape() returns a pointer to a shape
shape *load_shape()
It appears the program thinks line '3. shape2grammar(s)' is a call
where s is a pointer to the address of a shape (when I tried replacing
this with '3. shape2grammar(*s)' i get the error "no matching function
for call to 'shape2grammar(shape&)'")
but it's clear that what is returned by '2.s = load_shape()' is a
pointer to a shape because I tried accessing the members of s before
the call '3. shape2grammar(s)' (i.e. 's->num' works) and it seemed
fine.
Any suggestions would be appreciated.
Thanks,
Irvin H.