English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What are the types of class data and how do you decide which is appropriate? Explain the difference between declaring a variable using the keyword Public, Friend, or Private?

2006-07-04 15:42:13 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Components are like objects.
A textfield is a component
A label is a component
A slider is a component

Components is a group of classes that you plug into your project to make your programming easier. For instance I made a Openly Panel Component. What that does is when I drag the OpenGL Component to my Form, that would act as my OpenGL Window that I can do all my 3D modeling. Instead of recreating it, It is already done for me!

Say you made a radio within .NET, and you want to reuse it somewhere else, then the best thing to do is make that radio a component, that will have Stop Play Open,and each button would have its own event. So in other projects, you will just include that component within it.

Think of a package of Classes grouped together which are independent to its surroundings. In java it is called Packaged Jar Files, in C++ it is called libraries can be .lib or .dll. In .NET it is a .NET managed library.

I hope you now know the basic understanding of components which the most important is RE-USABILITY.

Now for your other question, when you declare a class, you will have a group of methods within it. For example we would make a class called Students. In that class Students we have getUsername getPassword and lets say getName as its functions.

class Student {
...
public Student(String username, String Password) { }
private string getName() { .. }
public bool authenticateLogin() { if(getName() == getPassword()) return true; else return false;}
private string getPassword() { .. }
....
}

Now when we declare some method PRIVATE, that will ONLY let that class use that method. When you create an instance of that class somewhere else, you CANNOT ACCESS THE PRIVATE VARIABLES. The only place where you can ACCESS THE PRIVATE VARIABLES are within that class. As you see in the above class, I could access the private methods.

class School {
public bool GOODtest() {
Student mystud = new Student("test","test");
if(mystud.authenticateLogin())
// YAY IT IS TRUE
else
// BOO IT IS FALSE
}
public bool BADtest() {
Student mystud = new Student("test","test");
mystud.getName();
// ERROR CANNOT ACCESS PRIVATE MEMBER
}
}

If you declare the keyword PUBLIC then it is accessible anywhere you instantiate it. Private is good for inner computation and programming that you don't want the outside world to know about.

IF you pick up a decent book about .object oriented design. You will learn vast amoiunt of knowledge. Too much to note down here.

2006-07-04 16:16:31 · answer #1 · answered by ? 6 · 1 0

in spite of if or not they opt to be approached, or left on my own is often the kind between approachable and not approachable. every physique might desire to be approached in a hypothetical concern, not all circumstances are hypothetical nonetheless. maximum persons %. up on while somebody desires to be left on my own, and while they experience like coming near human beings, they often enable human beings understand by ability of coming near human beings.

2016-12-08 15:46:28 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers