| re: pointers and so
Michael Sgier wrote:[color=blue]
> im quite new to C++ coming from VB.NET so I've troubles with
> the following pointer syntax. could someone explain me some
> terms?
> a) undefined reference to `CMD2Model::SetupSkin(SDL_Surface*&)
> what is undefined and what means *&[/color]
The function apparently was declared, used, but the definition of it is
not available to the compiler/linker so that the use could be resolved
to a proper function call. '*&' syntax is to declare a reference to
a pointer.
[color=blue]
> b) ((Cobject*)childnode)->Draw(camera)
> pointer to where? Could I write this in another way?[/color]
Here 'childnode' is _cast_ (using a C-style type cast) to a pointer to
an object of type 'Cobject'. The resulting value is used to access the
'Draw' member (and call it).
I do not know how to answer your question "pointer to where". As to
writing it "in another way", I'd need to know what 'childnode' is and
what 'Cobject' is. It is quite possible that if 'childnode' is declared
to be a pointer to type derived from 'Cobject', there is no need to cast
at all and you could write
childnode->Draw(camera)
but there is no way to tell for sure without knowing more about the
object and the type.
[color=blue]
> c)
> typedef struct
> {
> float s;
> float t;
> } texCoord_t;
> Hummm...any explainations here?[/color]
'texCoord_t' is declared to be a synonym to an unnamed type, a struct with
two members of type float. This is a usual way to declare an identifier
in C so later it could be used in declaring objects without the keyword
'struct'. In C++ it's unnecessary, and instead you should be using
struct texCoord_t
{
float s, t;
};
to define a type.
V |