Everything2
Near Matches
Ignore Exact
Full Text
Everything2

private

created by theFeeble

(idea) by moa (2.6 d) (print)   ?   I like it! Fri Aug 04 2000 at 1:00:49

In C++, this optional keyword starts declaring the private data members and/or member functions. The private members of a class are minimally accessible by other program parts.

It is invoked thus:

class foo
{
public:
//

protected:
//
private:
protected data members
protected member functions

}

The private section contains data members and member functions that are not accessible to class instances, to descendant classes, or to functions that do not belong to the class (such as the main() function). Typically, the private section contains highly sensitive data members and auxiliary member functions. Highly sensitive meaning data members that should work only with the private member functiosn of the calls. In other words, the private data members are conceptually "top secret" and should be handled by member functions that are themselves private.


(thing) by jawz (5.2 y) (print)   ?   I like it! Mon Oct 09 2000 at 7:43:23

Private is also a swedish porn company. Perhaps most famous for their uranus project. The porn movies from Private that i've seen, were all of a poor quality, meaning that the cutting was bad, the cameramen were lousy and the directing nonexisting. Othervise the actors were beautiful and the scenery often amazing.

(person) by DataJunkie (6 mon) (print)   ?   I like it! Sat Jul 07 2001 at 14:03:09

A Private is also the lowest ranking soldier in the United States Army and Marine Corps. His pay grade is that of an E1 or E2, the difference being an E1 is that you are a fresh-outta-boot camp recruit, with no insignia. After about 4-6 months of service, you are automatically promoted to Private E2. You then wear a standard triangular stripe (chevron) on your uniform, making you a full Private.

(thing) by ariels (13 hr) (print)   ?   I like it! Mon Sep 02 2002 at 16:26:30

C++ class member visibility:

In C++, members of the "private:" section(s) of a class (or struct) definition are visible only within members of that class. Outside that class, they are inaccessible, and cannot be used. In effect, the scope of their declaration does not extend beyond the class -- and C++ won't let you use something with no declaration in scope!

The following code snippet shows some of the behaviour. Lines with comments starting "*" are compilation errors; since we're discussing visibility, we must show them.

class X {
private:
  int a;
  int square() {
    return a*a;            // OK (1)
  }
  X(const X& y);           // Code outside class cannot invoke
                           // copy constructor.
public:
  X(int val) : a(val) {}
  int& add(const X& y) {
    return a += y.a;      // OK (1)
  }
};

class Y : public X {
private:
  void print() {
    std::cout << a;        // * NOT OK (2)
  }
};


X quadruple(X x)           // * NOT OK (3)
{
  x.add(x);
  x.add(x);
  return x;                // * NOT OK (3)
}

void f() {
  X a(2);                  // OK (4)
  X b(3);
  X c(a);                  // * NOT OK (5)
  a.add(b);                // OK
  std::cout << a.a;        // * NOT OK (6)
  std::cout << a.square(); // * NOT OK (6)
}

Notes:

  1. A member function of X may access private: members. Note that visibility is phrased in terms of the class, not in terms of the object. Thus, X::add(const X&) can see not just its own a (this->a), but also y.a. There is no way (in C++) to prevent this: visibility is not related to instances.
  2. The class of Y is not the class of X. (Contrast this to the fact that an instance of Y is an instance of X!) private: members of X are not visible in Y. You need protected: for that.
  3. X has a private: copy constructor. So code outside it cannot pass X parameters, and cannot receive X return values. Thus, quadruple cannot be used. The implicit use of the copy constructor is enough to break it.

    If you must pass such an X to a function, you can use a reference, which requires no copy.

  4. You can create an X from an int using its public constructor.
  5. You also cannot explicitly call X's copy constructor.
  6. And, of course, direct access to X's private parts is forbidden.

The default visibility of a class is private: (this is the only difference between it and struct).

Finally, note that nested classes aren't "inside" their containing class; a class X::Foo would also be unable to use private members of X.

C++ inheritance visibility:

You may also declare an inheritance relation between two classes "private". It is very similar to private: visibility of members: only member functions of the class may use that inheritance. But of course, even they are bound by the visibility of the parent class' methods (just like Y was, in the previous example).

This is hardly "inheritance" in the sense of an "is-a" relationship, at least not outside the class. But that's the whole point: anything outside the implementation cannot tell (from external behaviour) that the inheritance exists. Thus, private inheritance is sometimes used to model a "has-a" relationship; it is unclear whether this offers any benefits over having a member of the appropriate type.


(definition) by Webster 1913 (print) I like it! Wed Dec 22 1999 at 2:14:42

Pri"vate (?; 48), a. [L. privatus apart from the state, peculiar to an individual, private, properly p. p. of privare to bereave, deprive, originally, to separate, fr. privus single, private, perhaps originally, put forward (hence, alone, single) and akin to prae before. See Prior, a., and cf. Deprive, Privy, a.]

1.

Belonging to, or concerning, an individual person, company, or interest; peculiar to one's self; unconnected with others; personal; one's own; not public; not general; separate; as, a man's private opinion; private property; a private purse; private expenses or interests; a private secretary.

2.

Sequestered from company or observation; appropriated to an individual; secret; secluded; lonely; solitary; as, a private room or apartment; private prayer.

Reason . . . then retires Into her private cell when nature rests. Milton.

3.

Not invested with, or engaged in, public office or employment; as, a private citizen; private life.

Shak.

A private person may arrest a felon. Blackstone.

4.

Not publicly known; not open; secret; as, a private negotiation; a private understanding.

5.

Having secret or private knowledge; privy.

[Obs.]

Private actstatute, a statute exclusively for the settlement of private and personal interests, of which courts do not take judicial notice; -- opposed to a general law, which operates on the whole community. -- Private nuisancewrong. See Nuisance. -- Private soldier. See Private, n., 5. -- Private way, a right of private passage over another man's ground.

Kent.

 

© Webster 1913.


Pri"vate (?), n.

1.

A secret message; a personal unofficial communication.

[Obs.]

Shak.

2.

Personal interest; particular business.

[Obs.]

Nor must I be unmindful of my private. B. Jonson.

3.

Privacy; retirement.

[Archaic] "Go off; I discard you; let me enjoy my private."

Shak.

4.

One not invested with a public office.

[Archaic]

What have kings, that privates have not too? Shak.

5. Mil.

A common soldier; a soldier below the grade of a noncommissioned officer.

Macaulay.

6. pl.

The private parts; the genitals.

In private, secretly; not openly or publicly.

 

© Webster 1913.


printable version
chaos

Project Sifter Masturbation illegal Uranus Project
Money religion salary Oral sex
Swedish I could keep my sexuality private porn AOL is not the Internet
immoral The four levels of visibility in Java Vandy Girls Tattle tails
Walk Fast And Look Annoyed pirate Harold Patton quality
Secrets Americans E1 racism
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
What you are reading:
Lines in the mind
How to use a manual transmission
The Robot
Jim Crow
52
The Strong Programme
Eva Perón
The Russian Revolution: Fictional diary entries from a loyalist factory worker
The Old Man and the Sea
Dian Fossey
Halcyon
Ed stories
Katrina shelter
New Writeups
ncc05
overheard at IHOP(event)
lismaraxt
fellatrix(person)
calgon
Bottomless(poetry)
lismaraxt
Ice Theory of The Origin of Life(idea)
allthetime
Apple Cinnamon Suicide(idea)
Lucy-S
shovelglove(idea)
Adaptive Child
Mexican secret sauce(recipe)
Adaptive Child
nacho libre(recipe)
TheLady
Iron Man(review)
Scaevola
Risk in the Roman law of sale(idea)
semicolon
overheard at IHOP(event)
choirotey
Violent pickup lines(idea)
Ouzo
Blue Ovaries, Grrrrrrwl(log)
uncljoedoc
explanation(person)
Noung
One no longer loves one's insight when one communicates it(idea)
This page courtesy of The Everything Development Company