Syntax for implementing a function that returns a pointer

This is a discussion on Syntax for implementing a function that returns a pointer within the C++ Programming forums, part of the General Programming Boards category; I have a List class with a function that returns a pointer value and it is declared as follows in ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Location
    San Francisco, CA
    Posts
    5

    Syntax for implementing a function that returns a pointer

    I have a List class with a function that returns a pointer value and it is declared as follows in a header file:

    Code:
    Node *Find(int key);
    I want to implement this function but I have no idea how to do it properly when the return type is a pointer. A thought it might be something a long the lines of:

    Code:
    // in the .cc file
    
    
    List::Node *::List::Find(int key)
    {
    
    // My implementation code
    
    
    return nodePtr;
    
    }
    However, this doesn't work and my searches for something similar have come up blank thus far. Thank you so much for your help!

    Best regards.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,269
    This:
    Code:
    List::Node *::List::Find(int key)
    should be:
    Code:
    List::Node* List::Find(int key)
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2010
    Location
    San Francisco, CA
    Posts
    5
    Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is a virtual function pointer?
    By ting in forum C++ Programming
    Replies: 4
    Last Post: 03-05-2008, 02:36 AM
  2. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 10:09 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM

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