Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 25th, 2006, 10:13 AM   #1
n00b
Programmer
 
Join Date: Sep 2005
Posts: 69
Rep Power: 3 n00b is on a distinguished road
Send a message via MSN to n00b
c++ classes

why do methods belong to objects only logically, and not physically?
n00b is offline   Reply With Quote
Old Nov 25th, 2006, 10:36 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
Because methods (or member functions in C++ standardese) represent actions that are performed on (or by) an object. Static member functions represent actions that affect (eg visible to) all objects of a class.

The action of lifting your arm is something associated with you, but it is not physically part of you.

Even member functions that (say) return a reference to an internal data member can be described as allowing an action on that internal data member.
grumpy is offline   Reply With Quote
Old Dec 1st, 2006, 4:28 PM   #3
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
Or, an alternative answer that also seems logical: all instances of an object need their own separate copy of any non-static data members, because they may not be the same for the different instances. However, the methods will be the same for all instances, so what would be the point in physically giving each instance its own copy of the method?
__________________
"I'm not a genius. Why do I have to suffer?"
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Could some please explain classes to me... TCStyle C++ 10 Feb 20th, 2006 3:51 PM
What is Lightweight C++? difference in inner classes between C++ and Java? jonyzz C++ 4 Sep 2nd, 2005 9:56 AM
List of classes Dark_Shinobi C++ 8 May 23rd, 2005 3:50 PM
Classes Sane Python 8 Apr 29th, 2005 12:50 PM
C++ Classes - Quick question(s) Delete C++ 8 Apr 7th, 2005 7:38 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC