Thread: Private member functions of a class.

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    52

    Private member functions of a class.

    Before I yet again share with the world my ignorance, let me say that I've found this site and message board to be quite informative and extremely helpful. All lauds and acclaim aside, let me once again lech off of the more intelligent.

    I want to declare a private member function. Do I define it within the private member class? Here's what I'm thinking...

    Code:
    class Some_Class
    {
    private:
    
    long var_one;
    double var_two;
    char var_three[15];
    etc;
    
    float prive_function()
    {
    
    //function definition goes here....
    
    }
    
    //then public and so on
    How far off base am I? I intend to use a 'get' public function to access it, but the private function's purpose is to concatenate two strings (such as a first name and a last name). I know how to do all this (define the function), just not WHERE to put it. Perhaps I could be pointed in the proper direction to find how to go about doing this the proper way? I'm having a difficult time finding how to define it privately.

    Thank you

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    You're not offbase at all. Private member functions of a class are
    declared under private:, the same way that public member classes
    are declared under public:.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    just make sure that you dont define a body for your functions in the header file unless it's an inline function. Put the definitions in a separate .cpp file.

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can Nested class access parent class's private member?
    By meili100 in forum C++ Programming
    Replies: 4
    Last Post: 06-05-2009, 08:42 AM
  2. cannot access private member declared in class
    By newme in forum C++ Programming
    Replies: 7
    Last Post: 11-16-2008, 03:57 PM
  3. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  4. Class Templates and member functions
    By Mr_roboto in forum C++ Programming
    Replies: 7
    Last Post: 02-22-2006, 10:46 PM
  5. Private Static class members
    By earth_angel in forum C++ Programming
    Replies: 13
    Last Post: 08-29-2005, 06:37 AM