Thread: Member function

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    19

    Post Member function

    Can anyone explian to me why is there member function in c++?Is it because it would be easier to call functions for variables of the same type?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Just considering a class that is neither a derived class nor intended to be a base class: member functions in C++ are intended to access the implementation detail of the class, which generally means the private member variables of the class. This way, if the private member variables change, only the member functions need to be updated, at least in theory.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing member variable as default arg to member function
    By Memloop in forum C++ Programming
    Replies: 1
    Last Post: 09-08-2009, 06:49 PM
  2. Replies: 3
    Last Post: 07-23-2006, 01:09 PM
  3. member member function pointers
    By Bigbio2002 in forum C++ Programming
    Replies: 3
    Last Post: 12-04-2005, 05:14 PM
  4. Function Pointers to a Member, from a Member
    By littleweseth in forum C++ Programming
    Replies: 4
    Last Post: 11-01-2003, 02:12 AM
  5. private data member with public set member function
    By Mario in forum C++ Programming
    Replies: 2
    Last Post: 05-28-2002, 10:53 AM