Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > c can protect the data in struct

Reply
Thread Tools

c can protect the data in struct

 
 
Gordon Burditt
Guest
Posts: n/a
 
      02-28-2008
>c language can protect the data in scopes private,protected and
>public(may be) in structure and union?


No. There are no scopes private, protected and public in C.

You are looking for C++. And C++ cannot really protect (as in
prevent access) either. The protection only works if everyone obeys
the rules. All you have to do is invoke the wrath of undefined
behavior, often by loading up a pointer with something illegal, and
then using it.

 
Reply With Quote
 
 
 
 
yad.naveen@gmail.com
Guest
Posts: n/a
 
      03-12-2008
On Feb 28, 9:22*am, (E-Mail Removed) (Gordon Burditt) wrote:
> >clanguagecan protect the data in scopes private,protected and
> >public(may be) in structure and union?

>
> No. *There are no scopes private, protected and public inC.
>
> You are looking for C++. *And C++ cannot really protect (as in
> prevent access) either. *The protection only works if everyone obeys
> the rules. *All you have to do is invoke the wrath of undefined
> behavior, often by loading up a pointer with something illegal, and
> then using it.


In C There is no Private, Public,protected so there is no case of
protection.
in C++ There is Private ,Public Protected. If you follows rules it is
protected . if you are not following you still can access Private Data
even in C++.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
Typedef A references struct B which references struct A which... DanielEKFA C++ 8 05-16-2005 10:26 AM
struct in struct Gunnar G C++ 14 06-02-2004 06:43 PM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM
implementing a templated struct within a templated struct RA Scheltema C++ 3 01-06-2004 11:25 AM



Advertisments