Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How does C++ help with the tradeoff of safety vs. usability?



How does C++ help with the tradeoff of safety vs. usability? ..

Answer / abalonesoft

In C, encapsulation was accomplished by making things static
in a compilation unit or module. This prevented another
module from accessing the static stuff. (By the way, static
data at file-scope is now deprecated in C++: don't do that.)

Unfortunately this approach doesn't support multiple
instances of the data, since there is no direct support for
making multiple instances of a module's static data. If
multiple instances were needed in C, programmers typically
used a struct. But unfortunately C structs don't support
encapsulation. This exacerbates the tradeoff between safety
(information hiding) and usability (multiple instances).

In C++, you can have both multiple instances and
encapsulation via a class. The public part of a class
contains the class's interface, which normally consists of
the class's public member functions and its friend
functions. The private and/or protected parts of a class
contain the class's implementation, which is typically where
the data lives.

The end result is like an "encapsulated struct." This
reduces the tradeoff between safety (information hiding) and
usability (multiple instances).

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Interview Questions

what is object oriental programing?

1 Answers  


Why do we use int main instead of void main in c?

0 Answers  


Write a programme to find even numbers without using any conditional statement?

3 Answers   ADD Software, Infosys,


Is sizeof a keyword in c?

0 Answers  


Why ca not I do something like this?

0 Answers  


What is the code in while loop that returns the output of given code?

0 Answers  


what is difference between procedural language and functional language ?

4 Answers   Wipro,


find the output of the following program main() { int x=5, *p; p=&x; printf("%d",++*p); }

10 Answers   Amdocs, TCS,


main() { int ptr[] = {1,2,23,6,5,6}; printf("%d",&ptr[3]-&ptr[0]); }

8 Answers   Vector,


Write a program that accept anumber in words

0 Answers  


What is the difference between exit() and _exit()?

2 Answers  


how many error occurs in C language ?

22 Answers   Infosys, Wipro,


Categories