Thread: function defs outside of a derived class

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    221

    function defs outside of a derived class

    i have a basic class coord, which contains basic x,y,z and a few functions. derived from that class is target, which has functions that deal with the x,y,z manipulation

    i want those functions in target to be declaired outside of the class itself... how do i do that

    public Target::void depth_move(int direction)
    {
    }

    or what?

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Declared, or defined?
    Code:
    //declaration in .h file would be
    class Target{
    public:
           void depth_move(int direction);
    }
    
    //definition in .cpp file
    void Target::depth_move(int direction)
    {
    }

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Class target is derived from base class coord. Given that x, y, z are private members, then no global functions can access them. Why do you want global functions?

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Newbie - Derived Class Issue
    By Gipionocheiyort in forum C++ Programming
    Replies: 8
    Last Post: 08-01-2007, 12:20 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM