Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the benefit of private struct member??!!

Status
Not open for further replies.

maltobji

Programmer
Feb 13, 2001
31
JO
Dear ALL,
i want to ask about the benefit of having a private member in a certain struct .... who is able to access it ....

thanx in advance,
Mohammed Al-Tobji
Electrical Engineer
 
is the same benefit like having local variables in a functions John Fill
1c.bmp


ivfmd@mail.md
 
how can i create a private struct member?? bluenote@uyuyuy.com
(excuse my english)
 
it is possible in C++ only.
struct x
{
private:
//private members here
public:
//public members here
}; John Fill
1c.bmp


ivfmd@mail.md
 
thats what i thought bluenote@uyuyuy.com
(excuse my english)
 
My understanding of a struct was that everything was public. The definition of a struct that I got was it was a class with everything public but retained the size of only the data within. I have never used private in a struct but if private is allowed in a struct, john's suggestion above will do it.

matt
 
In C++ a struct is essentially the same thing as a class. You can created methods for the struct, both public and private as well as public and private data. The usage allows for encapsulation in a struct. However, the main uses in C++ for a struct are for compatability with C programs and creating structures with publicly accessable data.
 
Thanks all..... Mohammed Al-Tobji
Electrical Engineer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top