Thread: Defining Class memeber functions

  1. #1
    Registered User
    Join Date
    Dec 2003

    Defining Class memeber functions

    If a class member function is declared in the class definition this means that the client program can see the implementation of the function? This is what the book I have says but I don't quite understand what it means. When I think of implemenation I think source code. What makes defining a function in the class header any different than declaring a prototype and defining the function outside of the class?

  2. #2
    Join Date
    Jan 2002
    Defining a function within a class body is implicitly stating that the function is inline. Although you can define inline functions outside of the class declaration (but still in the same header file) you'd have to use the inline keyword explicitly. So the implementation is available to anyone with that header file.

    If you split definition and declaration between source and header files you could build an object/library containing the source code implementation and then distribute your lib/header pair for use by others. In this case the implementation would be hidden within the lib although the user could (necessarily) see the class declaration(s) from the header file.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Dec 2003
    Thanks ken, I think I have a better understanding now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  3. Replies: 3
    Last Post: 10-31-2005, 12:05 PM
  4. trouble defining member functions
    By dP munky in forum C++ Programming
    Replies: 7
    Last Post: 04-13-2003, 08:52 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM