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






December 12, 2005 03:09:01 #3
 pratiksha powar   Member Since: Visitor    Total Comments: N/A 

RE: 1.why do we need encapsulation?2. what is a ...
 

Analogue of C++ class in C:

We can have object-oriented implementation in C, by having a global function  which implements all the interfaces of an object.The particular function will use local data-structures and locally declared functions, which will be accessible only inside the gobal function not outside it.

The locally declared functions can be get-set methods or any sort of manipulation of the locally defined data-structure.

The global function itself acts like the  class.

The object creation and manipulation will be handled by this function alone.

     

 

Back To Question