CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.

Sponsored Links

Interview Questions
Our Services



INTERVIEW QUESTIONS PROGRAMMING LANGUAGES C++ DETAILS
Question :

mutable" Keyword - What is "mutable"?



Category C++ Interview Questions
Rating (3.8) By 12 users
Added on 7/16/2015
Views 67
Rate it!


Answers:

Source: CoolInterview.com

Answer1.
"mutable" is a C++ keyword. When we declare const, none of its data members can change. When we want one of its members to change, we declare it as mutable.

Answer2.
A "mutable" keyword is useful when we want to force a "logical const" data member to have its value modified. A logical const can happen when we declare a data member as non-const, but we have a const member function attempting to modify that data member. For example:

class Dummy {
public:
bool isValid() const;
private:
mutable int size_ = 0;
mutable bool validStatus_ = FALSE;
// logical const issue resolved
};

bool Dummy::isValid() const
// data members become bitwise const
{
if (size > 10) {
validStatus_ = TRUE; // fine to assign
size = 0; // fine to assign
}
}


Answer3.
"mutable" keyword in C++ is used to specify that the member may be updated or modified even if it is member of constant object. Example:

class Animal {
private:
string name;
string food;
mutable int age;
public:
void set_age(int a);
};

void main() {
const Animal Tiger(’Fulffy’,'antelope’,1);
Tiger.set_age(2);
// the age can be changed since its mutable
}

Source: CoolInterview.com




If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification Enter the above shown code: *
Inform me about updated answers to this question

Related Questions
View Answer
Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?

View Answer
Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].

View Answer
What are 2 ways of exporting a function from a DLL?
View Answer
What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?

View Answer
Explain term POLIMORPHISM and give an example using eg. SHAPE object: If I have a base class SHAPE, how would I define DRAW methods for two objects CIRCLE and SQUARE

.
View Answer
ell how to check whether a linked list is circular.
View Answer
Write a function that swaps the values of two integers, using int* as the argument type.

View Answer
Write a short code using C++ to print out all odd number from 1 to 100 using a for loop


View Answer
Write a program that ask for user input from 5 to 9 then calculate the average
View Answer
In the derived class, which data member of the base class are visible?

View Answer
STL Containers - What are the types of STL containers?
View Answer
How do you traverse a Btree in Backward in-order?
View Answer
What is pure virtual function?

View Answer
How can you tell what shell you are running on UNIX system?
View Answer
How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
View Answer
What is polymorphism?
View Answer
How do you write a function that can reverse a linked-list?

View Answer
What is a container class? What are the types of container classes?
View Answer
What is an orthogonal base class?
View Answer
What is a node class?
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View ALL C++ Interview Questions & Answers



User Options
India News Network

Latest 20 Questions
What's new with Webmail (OWA 2010)?
The look and feel of Office365 applications is different that Office 2010 ?
Will email space ever become unlimited?
Should we be concerned about HIPAA compliance ?
Is there an archive alternative to .pst files in Office365?
Instruction for migrate email between servers using IMAP ?
Requirement tools for migrate email between servers using IMAP ?
How do migrate email between servers using IMAP?
How to do Self-service migration ?
What is the problem you see with cut-over migrations?
How long does it take to run a single cut-over migration?
Should setup co-existence for our migration?
How do you handle the communications & change management for an email migration?
What is the impact on users compared to co-existence migrations?
What is XML Element?
What is CDATA?
Who is responsible for XML?
What is an XML Schema?
What is well formed XML document?
Why XML has been used for development?



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions



Cache = 0 Seconds