What does a subclass mean?

When reading articles, manuals, etc. about programming, I always come across the word qualified . as in java, the full class name will be com.example.Class. reading this article defines the scope :: operator in C ++ as used to define hidden names so that you can still use them. Is there a definition for this? Because it seems to be used in a different context each time.

+7
java c ++ computer-science
source share
2 answers

In computer programming, the full name is an unambiguous name that indicates which object, function, or variable is making a call, regardless of the context of the call. In a hierarchical structure, a name is fully defined when it is "completed" in the sense that it includes (a) all the names in a hierarchical sequence above a given element and (b) the name of the given element itself. "Thus, fully qualified names explicitly refer to namespaces, which would otherwise be implicit due to the volume of the call, although this is always done to eliminate ambiguity, it can mean different things depending on the context.

Wikipedia Source

In short, this means that

Your project may have a class called Math , but Math already present in Java.

So, to uniquely identify the class you are actually referring to, you also need to qualify the name in the package:

 java.lang.Math //refers to java class Math org.myproject.Math //refers to your project Math class 
+11
source share

From Merriam Webster

Complete definition of QUALIFY

transitive verb 1 a: reduce from general to a certain or limited form: change b: make it less severe or severe: moderate c: change strength or aroma d: limit or change meaning (as a noun) 2: characterize by naming the attribute: describe 3 a: be consistent with training, skill or ability for special purposes b (1): declare competent or adequate: certify (2): invest in legal capacity: license

Clauses 1 and 2 apply. Java and C ++ have scope / namespaces, and "qualify" means introducing enough areas to distinguish potential candidates.

Cf: If you have two classes with a member called "read".

 class Foo { void read(); }; class Bar { void read(); }; 

In your implementation file, you will perform both functions. But if you wrote (C ++)

 void read() {} 

This is valid, but it creates a function in the global namespace, and does not perform one of two functions. The same code written inside the class definition of Foo will implement Foo :: read.

So, in order to implement our member functions outside of class definitions, we need to qualify - to reduce from the general, to indicate the attribute of the path to the container - which we are reading.

 void Foo::read() {} void Bar::read() {} 

The global namespace is "::", so you can even be explicit if you are trying to use it:

 void ::read() {} // note: this name is already taken by stdio read() :) 
+2
source share

All Articles