Connecting Tech Pros Worldwide Forums | Help | Site Map

pointers and so

Michael Sgier
Guest
 
Posts: n/a
#1: Aug 17 '05
Hello
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 *&

b) ((Cobject*)childnode)->Draw(camera)
pointer to where? Could I write this in another way?

c)
typedef struct
{
float s;
float t;
} texCoord_t;
Hummm...any explainations here?

Thanks for your help!
Kind regards
Michael

Victor Bazarov
Guest
 
Posts: n/a
#2: Aug 17 '05

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
nan.li.g@gmail.com
Guest
 
Posts: n/a
#3: Aug 17 '05

re: pointers and so


a) This is a common linking error. Undefined reference means in your
code, you use some symbol( variable/function) defined outside. At
compile time, this is OK. But at link time, all undefined symbols
have to be resolved.

b)
c) I think you need to pick up a C/C++ book.

The C Programming Language (2nd Edition)
http://www.amazon.com/exec/obidos/tg...73650?v=glance
(The C book)

C++ Primer (4th Edition)
http://www.amazon.com/exec/obidos/AS...964370-1473650
(I have not read it, but it got good reviews)

The C++ Programming Language (Special 3rd Edition)
http://www.amazon.com/exec/obidos/tg...=UTF8&v=glance
(The C++ book)

Michael Sgier
Guest
 
Posts: n/a
#4: Aug 18 '05

re: pointers and so


Hello Victor
many thanks for your answers. I still dont know how to resolve
the
/home/michael/Desktop/div.OpenGL/projektdrei/src/projektdrei.cpp:283:
undefined reference to `Object3D::GetNextState()'

undefined reference error. the function GetNextState() is in
Object3D.cpp and there's also the Object3d.h all in the same
directory. What do I need to do?
Many thanks and regards
Michael
Victor Bazarov
Guest
 
Posts: n/a
#5: Aug 18 '05

re: pointers and so


Michael Sgier wrote:[color=blue]
> Hello Victor
> many thanks for your answers. I still dont know how to resolve
> the
> /home/michael/Desktop/div.OpenGL/projektdrei/src/projektdrei.cpp:283:
> undefined reference to `Object3D::GetNextState()'
>
> undefined reference error. the function GetNextState() is in
> Object3D.cpp and there's also the Object3d.h all in the same
> directory. What do I need to do?[/color]

Probably compile that file as well and provide the object file at
the link time. Since compiling/linking command-lines are compiler-
specific, you might be better off reading the documentation and/or
asking in the compiler newsgroup.

V
Closed Thread