VC++ problems with pointers

This is a discussion on VC++ problems with pointers within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I'm writting a function like this : Code: void GLMesh::convertToDiffCoord(Mesh *m) in this function i want to call ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    34

    VC++ problems with pointers

    Hi everyone,

    I'm writting a function like this :

    Code:
    void GLMesh::convertToDiffCoord(Mesh *m)
    in this function i want to call another function in the Mesh class, it's the function shown below:

    Code:
    list<Vertex*>* get_vertices(void) const;
    I want to use the object that is pointed by *m to call the function, so I wrote:

    Code:
    void GLMesh::convertToDiffCoord(Mesh *m)
    {
           list<Vertex*>* v = *m.get_vertices;
    }
    I keep getting error message saying:

    error C2228: left of '.get_vertices' must have class/struct/union
    1> type is 'Mesh *'
    1> did you intend to use '->' instead?

    which I don't understand.

    I'm a rookie in C++ programming, I would appreciate if any of you can give me some help.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    m->get_verticies(), maybe.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    or (*m).get_vertices, same thing.

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,272
    *m.get_vertices() is parsed as *(m.get_vertices()). Since m is a pointer, the dot cannot apply to it. So you must either use (*m).get_vertices(), or (far preferable) m->get_vertices().

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    34
    Thanks guys!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. problems passing pointers
    By doormat in forum C Programming
    Replies: 9
    Last Post: 04-11-2004, 05:38 PM
  3. Class Pointers
    By ventolin in forum C++ Programming
    Replies: 8
    Last Post: 04-04-2004, 07:07 PM
  4. Array of Pointers + Deleting An Object = Problems
    By Nereus in forum C++ Programming
    Replies: 3
    Last Post: 03-04-2004, 12:16 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21