--- In [email protected], Gopi Krishna Komanduri <gopikomand...@...> wrote:
>
> HI,
> One more query . I know that we can over loas const member functions by
> removing const. consider that I overloaded a const member function. Now
> consider that I declared a normal object (non-const). Now how can I access
> the const member functyion from non const object. As by default , this non
> const object will access non-const member function.
> example:
> class Base
> {
> public:
>
> Base()
> {
> //printf("\n I am in Base cons");
> }
> void show(int i) const
> {
> printf("\n the val if i is %d and is cons method",i);
> }
> void show(int i)
> {
> printf("\n I am in non const method");
> }
> };
> void main()
//I am surprised no one nit-picked on void to int conversion.
> {
> Base obj;
> Base const obj1;
> obj.show(20);
> obj1.show(20);
>
> // if I want to call show of non const using obj , if this not possible?
// Try to cast and see....
((const Base)(obj)).show(20);
// Can anyone tell how to use <const_cast> here? If it can be used.
//Assuming you change the return type for main, which you should by the way.
return EXIT_SUCCESS;
> }
>
>
> Explore and discover exciting holidays and getaways with Yahoo! India
> Travel http://in.travel.yahoo.com/
>
> [Non-text portions of this message have been removed]
>