Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Mar 9th, 2005, 9:32 AM   #1
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Accessor Funcs.

Could someone explain acessor funcitions for classes?

I really need some help here thanks
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Mar 9th, 2005, 11:29 PM   #2
meribia_pro_software
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 meribia_pro_software is on a distinguished road
Explanation of C++ Accessor Methods

Hey. I can help you; glad to be of assistance.

Accessor methods are part of object oriented programming, and are part of the interface that your class uses to communicate with the outside world, the outside world being, as a possibility, your main() function.

There are three parts to every class: protections (usually involving a private section and a public section), data members, and data methods.

Private data members are simply variables that happen to reside within the private section of your class, and cannot be accessed by a function that is not "owned" by your object.

Private data methods are simply functions that also reside within the private section of your class, and the same holds true.

Public data members and methods reside within the public section of your class and are able to be accessed anywhere in your program.

It's pretty clear what a public or private data member is (a variable like an int, char, or double), but an example of an accessor method whether public or private might make things clearer:

Here is a definition of a very concrete, easy to understand C++ object, which contains a single accessor method:

class Number {

private:

int n;

public:

// MultiplyInteger is our accessor method

int MultiplyInteger ( int p ) {

n *= p;

}

};

This is a very simple class, as you can see, but it demonstrates the concept.
I'll leave you to play around with the code as it is pretty self explanatory. Accessor methods aren't all that hard if you just remember that they are REGULAR FUNCTIONS wrapped up inside a C++ class framework.

That's it. Hope it helped.
meribia_pro_software is offline   Reply With Quote
Old Mar 10th, 2005, 9:47 AM   #3
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
lol, i use them all the time never knew what they were called though.
Berto is offline   Reply With Quote
Old Mar 10th, 2005, 6:47 PM   #4
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Thanks a bunch..even though I don't know really how to use pointers that much either. But thanks all the same.
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Mar 11th, 2005, 10:41 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Where's the pointers?
__________________
Me :: You :: Them
Ooble 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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:51 PM.

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