GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 92 of 203    Print  
Why cann't we overload the sizeof, :?, :: ., .* operators in c++

  
Total Answers and Comments: 4 Last Update: July 31, 2009     Asked by: surya 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Andrew Berstan
 
Because it will not help write a clear program. If we overload sizeof, :?, ::, it will cause a lot of confuse rather than make program more easier to understand.

Above answer was rated as good by the following members:
yzesong
August 10, 2006 10:24:10   #1  
sabita        

RE: Why cann't we overload the sizeof, :?, :: ., .* op...
The restriction is for safety.For example if we overload . operator then we cant access member in normal way for that we have to use ->.
 
Is this answer useful? Yes | No
August 12, 2006 01:42:47   #2  
Andrew Berstan        

RE: Why cann't we overload the sizeof, :?, :: ., .* op...
Because it will not help write a clear program. If we overload sizeof :? :: it will cause a lot of confuse rather than make program more easier to understand.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
September 05, 2006 05:18:49   #3  
Amritanshu Agrawal        

RE: Why cann't we overload the sizeof, :?, :: ., .* op...

Hi all

Firstof all only . :: and .* operators never be overladed.

Because They take name rather than a value as their socound operand and provide the primary means of reffering to members.Allowing them to be overloaded would lead to subtlety.


 
Is this answer useful? Yes | No
July 31, 2009 17:27:23   #4  
yzesong Member Since: July 2009   Contribution: 20    

RE: Why cann't we overload the sizeof, :?, :: ., .* operators in c++
In order to avoid operator ambiguity :? :: . operators are not overloaded.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape