?
Solved

Constant objects

Posted on 1998-10-08
2
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

764 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