GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 175 of 185    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: 3 Last Update: September 11, 2008     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
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 1   Answer is not useful 0Overall Rating: +1    
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 1Overall Rating: -1    
September 11, 2008 09:08:13   #3  
OSaienni Member Since: September 2008   Contribution: 8    

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


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape