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  >  Concepts  >  OOPS

 Print  |  
Question:  1.why do we need encapsulation?
2. what is a class in C++ analogous to in C






February 02, 2006 08:19:40 #4
 Scott Sehlhorst Testing Expert  Member Since: February 2006    Total Comments: 8 

RE: 1.why do we need encapsulation?2. what is a ...
 
We need encapsulation to minimize the cost of maintaining the code. When we hide the internal structure of an object, we force other objects to talk to it through a specific API. This is contract based programming. Now we can test just this object (API inputs and inspect outputs) independently of other classes. We can also make changes to this class without affecting other parts of the software - because the changes are encapsulated to the single class.Also makes it easier for multiple people to work on the same project in parallel.
     

 

Back To Question