Solved

Constant objects

Posted on 1998-10-08
2
191 Views
Last Modified: 2010-04-02
Hi friends,
          Why is it not possible to invoke a nonconstant member function using a constant object?.Thanks a lot.
0
Comment
Question by:tmmet
2 Comments
 
LVL 1

Accepted Solution

by:
Booth882 earned 0 total points
ID: 1174699
because that is the whole idea behind constant objects, that you cant change anything in it.  functions that are not declared const are able to change the data in an object and therefore would defeat the whole purpose of declaring it const in the first place, so const objects are not allowed to call them.  it is one more instance of rigid c++ object oriented programming
0
 
LVL 22

Expert Comment

by:nietod
ID: 1174700
tmmet, these are beginning to sound a lot like homework questions.  We can ASSIST you on your homweork to some degree, but we cannot do it for you.   That is unethical and is cause for removal from EE (for both you and us).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now