What is CrazyEngico.com (CE)?

CrazyEngico (CE) is a one-stop solution for interview questions and answers, domain knowledge, e-learning, tutorials, articles and many more learning material.
e-learning - Intelligent e-learning tutorials and articles
Domain Knowledge Learn about various business domains/verticals such as Banking, Financial, Insurance, Healthcare and many more...
Interview Questions and Answers - Post your questions and answers. 1000+ database of ready questions and answers available to prepare for an interview.
Tutorials - 300+ video tutorials from beginner to expert level.
Articles - 300+ technical articles to understand concepts.
Forum - A technical forum to post your queries/responses.

Search Questions

Interview Questions/Answers

Interview Q & A >> C++ >> What is an accessor?

<< Previous Question Navigator Next >>

0        0
What is an accessor? (Views: 1103)


0        0

An accessor is a class operation that does not modify the state of an object. The accessor functions need to be declared as const operations.

Submitted By: Anonymous | Created On: 7/13/2009 9:39:02 AM

0        0

An accessor function in C++ is like the getter and setter functions in C#. This is used instead of making a class member variable public and changing it directly within an object, It is made private and not directly accessible. To read or modify the object member, an accessor function must be called.
Typically for a member such as Level, a function GetLevel() would return the value of Level and SetLevel() to assign it a value.
 class CLevel {
 int Level;
 int GetLevel() {return Level;} ;
 void SetLevel(int NewLevel) { Level=NewLevel;} ;

Submitted By: EMRAN | Created On: 8/4/2011 5:12:16 AM

Post your Answer
Your answer will be first reviewed by our administrator before it appears on the site.

Your Answer:

Display Name:

By clicking on Submit button you agree to the Terms of Service agreement.

Copyright © 2018 CrazyEngico.com. All rights reserved.
CrazyEngico.com is not responsible for the content and CrazyEngico.com does not evaluate or guarantee the accuracy of any CrazyEngico.com content.
Please read our terms of service agreement before using this site.