GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 175 of 203    Print  
Member Access
Which one of the following statements is FALSE?
A. The access privileges in C++ are private, protected and public.
B. The default access level assigned to members of a class is private.
C. Public members of a class can be accessed by everyone.
D. Private members of a class can be accessed only within the class.
E. Protected members are accessible by its sub-classes.



  
Total Answers and Comments: 4 Last Update: February 16, 2009     Asked by: prettyfox 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: wael.salman
 
D is wrong.It can be accessed by friend function also.

Above answer was rated as good by the following members:
OSaienni, yzesong
August 01, 2008 21:24:39   #1  
wael.salman Member Since: July 2008   Contribution: 6    

RE: Member Access
D is wrong.It can be accessed by friend function also.
 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
August 12, 2008 04:00:59   #2  
user_cpp Member Since: August 2008   Contribution: 1    

RE: Member Access
C is wrong as class variables can only be used using class objects not by anyone.
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 2Overall Rating: -2    
September 11, 2008 09:08:13   #3  
OSaienni Member Since: September 2008   Contribution: 7    

RE: Member Access
C. Public members of a class can be accessed by everyone

True.

Look here

class CTest

{

public: int m_n;

};


class COther

{

public:

COther(CTest &obj)

{

obj.m_n 1; //also okay

}

};


int main()

{

CTest objTest;

objTest.m_n 2; //okay and not class modifing it.

COther objOther(objTest);

}

As you can see the public member m_n in object CTest is accessible everywhere.


 
Is this answer useful? Yes | No
February 16, 2009 04:16:56   #4  
santhosh.kanchanapally Member Since: April 2008   Contribution: 10    

RE: Member Access
Protected members are accessible by its sub-classes.

Protected members are not acceble by its sub classes as when they inherit base class protected variables of base class becomes private to sub class. So it can't access.

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    


 
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