/** @page qore_classes Classes

    @tableofcontents

    @section class_overview Class Overview
    Classes define types of %Qore @ref object "objects". Classes can define members and methods, which are attributes of the class and functions that operate only on the objects of that class, respectively.  Furthermore access to class members and methods can be restricted with the <tt><b>private</b></tt> or <tt><b>private:internal</b></tt> access modifiers, and classes can be @ref inheritance "subclassed" to support polymorphism.

    A class can have any valid identifier name except \c "auto" but may not have the same name as a child namespace of the namespace parent object.

    @note Each %Qore type has a "pseudo-class" associated with it (the default is @ref Qore::zzz8valuezzz9); methods from the data type's "pseudo-class" can be run on any value of that type; see @ref Qore::zzz8valuezzz9 and <b>"Pseudo Class for Type"</b> headings in @ref basic_data_types for more information.

    @par In-Line Class Declaration Syntax
    <tt><b>[@ref mod_public "public"] [@ref final_classes "final"] class</b> [</tt><em>@ref namespace_paths "namespace_path"</em><tt>::...]</tt><em>class_identifier</em><tt>] [<b>inherits</b> [<b>@ref private_inheritance "private[:internal|hierarchy]"</b>|<b>@ref public_inheritance "public"</b>] [</tt><em>@ref namespace_paths "namespace_path"</em><tt>::...]</tt><em>parent_class_identifier</em><tt>[, ...]] {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[[<b>@ref private_members "private[:internal|hierarchy]"</b>] [<b>@ref transient "transient"</b>] </tt><em>member_name</em><tt>[, ...];]</tt>\n\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[<b>@ref private_members "private[:internal|hierarchy]"</b>|<b>@ref public_members "public"</b> {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<tt>[[<b>@ref transient "transient"</b>] [</tt><em>@ref data_type_declarations "member_type"</em><tt>] </tt><em>member_name</em> <tt>[= </tt><em>@ref expressions "initialization_expression"</em><tt>];]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<tt>[<b>static</b> [</tt><em>@ref data_type_declarations "static_member_type"</em><tt>] </tt><em>static_member_name</em> <tt>[= </tt><em>@ref expressions "initialization_expression"</em><tt>];]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<tt>[<b>const</b> </tt><em>constant_name</em> <tt>=</tt> <em>@ref expressions "initialization_expression"</em><tt>;]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>}]</tt>\n\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[[<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [<b>@ref deprecated "deprecated"</b>] <b>constructor</b>([</tt><em>@ref data_type_declarations "[param_type]"</em> <em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]) [: </tt><em>parent_class_name</em><tt>(</tt><em>args...</em><tt>), ...] {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>}]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[<b>copy</b>(<tt>@ref object_type "object" </tt><em>arg_name</em>) {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>}]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[<b>destructor</b>() {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>}]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[[<b>@ref static_methods "static"</b>|<b>@ref final_methods "final"</b>] [<b>@ref synchronized "synchronized"</b>] [<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [<b>@ref deprecated "deprecated"</b>] [</tt><em>@ref data_type_declarations "return_type"</em><tt>]</tt> <em>method_name</em><tt>([</tt><em>@ref data_type_declarations "[param_type]"</em> <em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]) {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>}]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[[<b>@ref abstract "abstract"</b>] [<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [</tt><em>@ref data_type_declarations "return_type"</em><tt>]</tt> <em>method_name</em><tt>([</tt><em>@ref data_type_declarations "[param_type]"</em> <em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]);]</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>...</tt>\n
    <tt>}</tt>

    @note To define a class interface, define a class with @ref abstract "abstract methods".

    When defining a @ref user_modules "user module", class declarations can be preceded by @ref mod_public "public", which means that the class will be available (imported) in the @ref Qore::Program "Program" object importing the module.  When a class is declared @ref mod_public "public" outside of a @ref user_modules "user module", it means that the class can be inherited in any child @ref Qore::Program "Program" objects created in the same scope. See @ref mod_public "public" for more information. Note that classes can also be imported singly by using the @ref Qore::Program::importClass() "Program::importClass()" method.

    @par In-Line Class Declaration Example
    @code{.py}
class MyClass inherits MyBaseClass {
    public {
         string pub_attr = "hello";
	 const pub_const = "foo";
	 static pub_static_var = "bar";
    }

    constructor(string arg) : MyBaseClass(arg + 1) {
    }

    softstring myMethod(softint i) {
        return i + 2;
    }
}
    @endcode

    @note No semicolon (\c ";") is required to terminate a class declaration (in fact using a semicolon would raise a parse exception).

    @par Out-Of-Line Class Declaration Syntax
    Alternatively class declarations and method declarations can be defined out of line as follows:\n
    <tt>[@ref mod_public "public"] \b class [</tt><em>@ref namespace_paths "namespace_path"</em><tt>::...]</tt><em>class_identifier</em><tt> [<b>inherits</b> [<b>@ref private_inheritance "private[:internal|hierarchy]"</b>|<b>@ref public_inheritance "public"</b>] [</tt><em>@ref namespace_paths "namespace_path"</em><tt>::...]</tt><em>parent_class_identifier</em><tt>[, ...]];</tt>\n\n
    <tt>[[<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [<b>@ref deprecated "deprecated"</b>] [</tt><em>@ref namespace_paths "namespace_path"</em><tt>::...]</tt><em>class_identifier</em><tt>::<b>constructor</b>([</tt><em>@ref data_type_declarations "[param_type]"</em> <em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]) [: </tt><em>parent_class_name</em><tt>(</tt><em>args...</em><tt>), ...] {</tt>\n
    <tt>}]</tt>\n\n
    <tt>[[<b>@ref static_methods "static"</b>|<b>@ref final_methods "final"</b>] [<b>@ref synchronized "synchronized"</b>] [<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [<b>@ref deprecated "deprecated"</b>] [</tt><em>@ref data_type_declarations "return_type"</em><tt>] [</tt><em>@ref namespace_paths "namespace_path"<tt>::...]</tt>class_identifier</em><tt>::</tt><em>method_name</em><tt>([</tt><em>@ref data_type_declarations "[param_type]"</em> <em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]) {</tt>\n
    <tt>}]</tt>
    <tt>[<b>@ref abstract "abstract"</b> [<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [</tt><em>@ref data_type_declarations "return_type"</em><tt>] [</tt><em>@ref namespace_paths "namespace_path"<tt>::...]</tt>class_identifier</em><tt>::</tt><em>method_name</em><tt>([</tt><em>@ref data_type_declarations "[param_type]"</em> <em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]);</tt>\n

    As with inline class definitions, when defining a @ref user_modules "user module", class declarations can be preceded by @ref mod_public "public", which means that the class will be available (imported) in the @ref Qore::Program "Program" object importing the module. When a class is declared @ref mod_public "public" outside of a @ref user_modules "user module", it means that the class can be inherited in any child @ref Qore::Program "Program" objects created in the same scope. See @ref mod_public "public" for more information. Note that classes can also be imported singly by using the @ref Qore::Program::importClass() "Program::importClass()" method.

    @par Out-Of-Line Class Declaration Example
    @code{.py}
class MyNamespace::MyClass inherits MyBaseClass;

MyNamespace::MyClass::constructor(string arg = "temp") : MyBaseClass(arg + ".txt") {
}

softstring MyNamespace::MyClass::myMethod(softint i) {
    return i + 2;
}
    @endcode

    @note Because method definitions are allowed out-of-line, this means that builtin classes may be extended with new user methods, however user constructor, destructor, and copy methods cannot be added to builtin classes; to customize the behavior of these methods for builtin classes, subclass the class instead.\n\n
    When parse option @ref allow-bare-refs "%allow-bare-refs" or @ref new-style "%new-style" is enabled, no \c "$" or \c "$." prefixes can be used with variable or method or member names.
    Class members, class constants, and static class variables can only be declared in an in-line class definition (the first example above). If a class has at least one public member declared (or inherits a class with at least one public member declared), then only those members declared as public can be accessed from outside the class, and from within the class only members explicitly declared can be accessed as well (unless the class also defines a memberGate() method). In this way typographical errors in member names can be caught (at parse time if types are declared).\n\n
    In a class hierarchy, base class constructor methods can be explicitly specified using a special syntax unique to subclass constructor methods. Please see @ref inheritance for more information.\n\n
    It's possible to write purely object-oriented scripts/programs in %Qore by defining an application class and using the \c "-x" or \c "--exec-class" command-line arguments to tell %Qore to instantiate the class instead of doing normal top-level execution (in fact, the \c "--exec-class" argument disallows the use of top-level statements entirely). For more information, please see @ref command_line_processing and @ref parse_directives.

    @subsection final_classes Final Classes
    Classes declared <b><tt>final</tt></b> cannot be subclassed, and, by extension, no methods of a <b><tt>final</tt></b> class can be reimplemented as well.\n\n
    Currently the %Qore standard class library (delivered with %Qore) has no <b><tt>final</tt></b> classes.

    @section class_methods Class Methods

    @subsection public_methods Public Methods
    All class methods are public by default, but methods can also be explicitly declared with the <tt><b>public</b></tt> access modifier as well.  Public methods have no class protection and can be called from any code context.

    @subsection private_methods Private Methods
    Methods declared with the <tt><b>private</b></tt> access modifier can only be called by other member methods of the same class or in the same class hierarchy. Any attempt to call these methods from outside the class hierarchy will result in a run-time exception.  This access modifier, when used without any modifiers, is equivalent to <tt><b>private:hierarchy</b></tt> and is functionally identical to C++'s \a protected access modifier.\n\n
    Methods declared as <tt><b>private:internal</b></tt> are not available outside the class, even in classes in the same class hierarchy, providing strong encapsulation of the declared method.  This can be used to ensure that the declared method can be changed in later versions of the class without affecting API compatibility.\n\n
    Methods declared as <tt><b>private:hierarchy</b></tt> are equivalent to those declared <tt><b>private</b></tt> and are only private from outside the class hierarchy.

    @subsection synchronized_methods Synchronized Methods
    Methods declared with the <tt><b>synchronized</b></tt> keyword will only run in one thread at a time.\n\n
    <tt><b>synchronized</b></tt> normal class methods share a reentrant lock associated with the object, while <tt><b>synchronized</b></tt> static class methods share a reentrant lock associated with the class itself.\n\n
    For more information, see the @ref synchronized "synchronized keyword".

    @subsection static_methods Static Methods
    Methods declared with the <tt><b>static</b></tt> keyword are like regular functions that are attached to the class. These methods are not associated with a particular object's state and therefore are not allowed to refer to object members or call non-static methods. Also, no reference to the special <tt>self</tt> variable is allowed within static methods.\n\n
    Static methods may be declared <tt><b>private</b></tt>, <tt><b>private:internal</b></tt>, or <tt><b>public</b></tt> or <tt><b>synchronized</b></tt> like non-static methods; static methods can also access private members of a class (through an object of the class for non-static members).   Static methods may not be also @ref abstract "abstract".\n\n
    Static method calls take a special syntax as documented in @ref static_method_calls .\n

    @subsection abstract Abstract Methods
    Methods declared with the <tt><b>abstract</b></tt> keyword define methods interfaces that must be defined in child
    classes for the class to be instantiated.  Methods defining the declared interfaces in child classes must define
    exactly the same parameters in order for the abstract method to match, but the return type of the concrete method
    in the child class has to simply be compatible with the return type of the abstract method in the parent
    class.\n\n
    Classes with undefined abstract methods cannot be instantiated.  Abstract methods cannot have a method body; an
    abstract method's declaration must be terminated with a semicolon (\c ";").  Furthermore, abstract methods cannot
    be also @ref static_methods "static".\n\n
    The <tt><b>abstract</b></tt> keyword can only be used in abstract method declaration; the use of this keyword
    with a method declaration with a method body will cause a parse exception to be thrown.\n\N
    @note Ellipses (\c "...") may be provided as the only or last parameter, indicating the the method takes a
    variable number of arguments. This is most important with @ref abstract "abstract" class methods and any concrete
    methods in child classes implementing the abstract method, as the ellipses must match, or the method will not be
    overridden.

    @subsection class_special_methods Constructors, Destructors, and Other Special Methods
    All class methods are optional, but some methods have a special meaning.\n\n
    <b>Special Methods</b>
    |!Name|!Description
    |<tt>constructor(</tt><em>[params...]</em><tt>) {}</tt>|Called when objects are created when instantiated by a variable declaration with a class type and constructor arguments or explicitly with the new operator. User code may not explicitly call \c constructor() methods directly. In a class tree, \c constructor() methods are called for base classes first in left-to-right, depth-first declaration order.\n\n\c constructor() methods may be @ref overloaded_methods "overloaded" and also private constructors may be defined.  Constructors declared <tt><b>private</b></tt> can only be called from within the class hierarchy, and those declared <tt><b>private:internal</b></tt> can only be called within the class itself.
    |<tt>copy() {}</tt>|When a user explicitly calls a copy method, %Qore will generate a new object with references to the same members as the source object. Then, if there are any base classes, base class \c copy() methods are called in the same order as the \c constructor() methods. If a \c copy() method is defined, it will be run in the new object with a reference to the old object passed as the first argument. Any other arguments passed to the \c copy() method are ignored.\n\n\c copy() methods cannot be @ref overloaded_methods "overloaded" and cannot be private.
    |<tt>destructor() {}</tt>|Called when objects are implicitly collected (see @ref garbage_collection) or are explicitly deleted. User code may not explicitly call \c destructor() methods. In a class tree, \c destructor() methods are called for base classes in the opposite order in which the constructors are called.\n\n\c destructor() methods cannot be @ref overloaded_methods "overloaded" and cannot be private.
    |@ref any_type "any" <tt>@ref memberGate_methods "memberGate"(</tt>@ref string_type "string" <tt>$</tt><em>member_param_name</em><tt>) {}</tt>|If this method is implemented in the class, it is called when read access is attempted to private member or members that do not exist in the current object; the return value of this method is returned as the value of the member.\n\n\c memberGate() methods cannot be @ref overloaded_methods "overloaded" and are not inherited by subclasses.
    |@ref any_type "any" <tt>@ref methodGate_methods "methodGate"(</tt>@ref string_type "string" <tt>$</tt><em>method_param_name</em><tt>, ...) {}</tt>|If this method is implemented in the class, it is called when methods are called on the object that do not exist in the current object and the return value of this method is returned as the value of the method call.\n\n\c methodGate() methods cannot be @ref overloaded_methods "overloaded" and are not inherited by subclasses.
    |<tt>@ref memberNotification_methods "memberNotification"(</tt>@ref string_type "string" <tt>$</tt><em>member_param_name</em><tt>) {}</tt>|If this method is implemented in the class, it is called when an object member is updated outside the class with the member name as the argument. Note that this method is called after the member has been updated and without locking; the call is not atomic respective to other threads that also may update the same member simultaneously.\n\n\c memberNotification() methods cannot be @ref overloaded_methods "overloaded" and are not inherited by subclasses.

    @subsection final_methods Final Methods
	Methods declared <b><tt>final</tt></b> cannot be reimplemented in a subclass.  Methods can be declared <b><tt>final</tt></b> to prevent a subclass from altering the behavior of a method that is critical to the class's functionality.\n\n
	None of the following special methods can be declared <b><tt>final</tt></b>:
	- constructor(): declare the class @ref final_classes "final" instead
	- destructor(): declare the class @ref final_classes "final" instead
	- copy(): declare the class @ref final_classes "final" instead
	- @ref memberGate_methods "memberGate()": these methods are not inherited so they may not be declared <b><tt>final</tt></b>
	- @ref memberNotification_methods "memberNotification()": these methods are not inherited so they may not be declared <b><tt>final</tt></b>
	- methodGate(): these methods are not inherited so they may not be declared <b><tt>final</tt></b>

    @subsection class_method_param_varargs Ellipses For Variable Arguments

    Ellipses (\c "...") may be provided as the only or last parameter for any method, indicating the the method takes
    a variable number of arguments.

    This is most important with @ref abstract "abstract" class methods.

    @subsection class_constants Class Constants
    Class constants, like non-class constants, allow programmers to refer to values with %Qore identifiers rather than using the value or the expression that generates the value.\n\n
    See @ref class_overview for a description of the syntax required to declare a class constant.\n\n
    Like other attributes of classes, class constants may be declared <tt><b>private</b></tt>, <tt><b>private:internal</b></tt>, or <tt><b>public</b></tt>. The following are examples of class constant definitions:\n
    @code{.py}
class Test {
    public {
        const Version = "1.0";
    }

    private {
        const Limit = 100;
    }

    private:internal {
        const Other = "string";
    }
}
    @endcode

    @note Class constants cannot have the same names as @ref static_class_variables "static class variables".

    @subsection static_class_variables Static Class Variables
    Static class variables are like global variables that belong to a class. They are not associated with any particular object.\n\n
    See @ref class_overview for a description of the syntax required to declare a static class variable.\n\n
    Like other attributes of classes, static class variables may be declared <tt><b>private</b></tt>, <tt><b>private:internal</b></tt>, or <tt><b>public</b></tt>. The following are examples of static class variable definitions:\n
    @code{.py}
class Test {
    public {
        static string lastFile = "none";
    }

    private {
        static int numProcessed = 0;
    }

    private:internal {
        static string other = "string";
    }
}
    @endcode

    @note Static class variables cannot have the same name as class constants.

    @section class_members Class Members

    @subsection public_members Public Member Declarations
    If a class has at least one public member declared (or inherits a class with at least one public member declared), then only those members declared as public can be accessed from outside the class, and from within the class only members explicitly declared can be accessed as well (unless the class also defines a @ref memberGate_methods "memberGate() method"). In this way typographical errors in member names can be caught (at parse time if types are declared).

    @subsection private_members Private Members
    Members declared <b><tt>private</tt></b> can only be accessed within the class hierarchy; trying to access private members form outside the class hierarchy will result in either a parse or runtime exception, depending on when the illegal access is caught.  This access modifier, when used without any modifiers, is equivalent to <tt><b>private:hierarchy</b></tt> and is functionally identical to C++'s \a protected access modifier.\n\n
    Members declared as <tt><b>private:internal</b></tt> are not available outside the class, even in classes in the same class hierarchy, providing strong encapsulation of the declared member.  This can be used to ensure that the declared member can be changed in later versions of the class without affecting API compatibility.\n\n
    Members declared as <tt><b>private:hierarchy</b></tt> are equivalent to those declared <tt><b>private</b></tt> and are only private from outside the class hierarchy.

    @subsection transient Transient Members
    Members declared with the <b><tt>transient</tt></b> keyword will not be processed with @ref Qore::Serializable "object serialization"
    and will get their default value (if any) when deserialized.

    @subsection referencing_members Class Member References
    When defining a class when using the old style syntax, members of instantiated objects are referred to with a special syntax as follows:\n
    <tt>$.</tt><em>member_name</em>\n\n
    Furthermore, the automatic variable <tt>self</tt> is instantiated in every non-static method, representing the current object (similar to <tt>this</tt> in C++ or Java). Therefore if you need to access hash members which are not valid %Qore identifiers, then enclose the member name in double quotes after the dot operator as follows:\n
    @code{.py} self."&member-name"@endcode

    @subsection memberGate_methods memberGate() Method
    If the class implements a \c memberGate() method, then whenever a non-existent member of the class is accessed (read), this method will be called with the name of the member as the sole argument, so that the class can create the member (or react in some other way) on demand. This method is also called when methods of the same class try to access (read) non-existent methods, but is not called from within the \c memberGate() method itself.

    @note \c memberGate() methods are not inherited; they must be explicitly implemented in each class

    @subsection memberNotification_methods memberNotification() Methods
    To monitor writes to the object, the class can implement a \c memberNotification() method, which is called whenever an object member is modified from outside class member code. In this case, the \c memberNotification() method is called with the name of the member that was updated so that an object can automatically react to changes to its members (writes to members) from outside the class. This method is not called when members are updated from within class member code.

    @note \c memberNotification() methods are not inherited; they must be explicitly implemented in each class

    @subsection member_initialization Member Initialization
    Members that have intialization expressions in the class definition are initialized before the constructor is executed (but after any base class constructors have run).  An exception raised in a member initialization expression will cause the constructor to fail and for the object to be deleted immediately.

    @note The automatic <tt>argv</tt> local variable is instantiated as usual in all class methods where there are more arguments than variables declared in the method declaration.\n\n

    @section object_method_calls Object Method Calls

    @par In-Class Method Call Syntax
    Within a class method definition, calls to methods in the same class hierarchy (of the current class or a base class) can be made as follows:\n
    <tt>[[</tt><em>@ref namespace_paths "namespace_path"</em><tt>::...]</tt><em>parent_class_name</em><tt>::]$.</tt><em>method_name</em><tt>([</tt><em>args</em><tt>, ...])</tt>

    @par In-Class Method Call Example
    @code{.py}
# to call a specific method in a base class
Thread::Mutex::lock();
# to call lock() in the current (or lower base) class
lock();
    @endcode

    @par In-Class Method Calls with %allow-bare-refs
    When the @ref allow-bare-refs "%allow-bare-refs" or @ref new-style "%new-style" parse directive is set, then object methods are called without the \c "$." prefix as in the following example:\n
    @code{.py}
# to call a specific method in a base class
Thread::Mutex::lock();
# to call lock() in the current (or lower base) class
lock();
    @endcode\n
    Calls to object methods can be made outside the class by using the above syntax as well. If the object's class is not known at parse time, then the call is resolved at run-time, and if a call is attempted to a private function outside the defining class, then a run-time \c METHOD-IS-PRIVATE (if the method is private) or \c BASE-CLASS-IS-PRIVATE (if the method resolves to a privately-inherited base class) exception is raised.

    @anchor methodGate_methods
    @par methodGate() methods
    If the class implements a \c methodGate() method, then whenever a non-existent method of the class is called, the methodGate() method will be called with the name of the member as the first argument (prepended to the other arguments to the non-existant method), so that the class simulate or redirect the method call.  This method is also called when methods of the same class try to call non-existent methods, but is not called from within the \c methodGate() method itself.

    @note \c methodGate() methods are not inherited; they must be explicitly implemented in each class

    @section inheritance Class Inheritance

    Class inheritance is a powerful concept for easily extending and reusing object-oriented code, but is also subject to some limitations. This section explains how class inheritance works in %Qore.

    Classes inherit the methods of a parent class by using the <tt><b>inherits</b></tt> keyword as specified above.  Multiple inheritance is supported; a single %Qore class can inherit one or more classes.  When a class is inherited by another class, it is called a base class or parent class.  @ref private_inheritance "Private inheritance" is specified by including the <tt><b>private</b></tt> access modifier before the inherited class's name.  When a class is privately inherited, it means that the inherited class's public declarations (members, constants, methods, etc) are treated as private in the context of accesses outside the class hierarchy.

    To limit access of a base class to only the directly inheriting class, use the <tt><b>private:internal</b></tt> access modifier.  Classes inherited with <tt><b>private:internal</b></tt> are not accessible to the hierarchy in general but rather only to the directly inheriting class.

    Inheritance is <tt><b>public</b></tt> @ref public_inheritance "by default", to inherit a class privately, such that the inherted class is accessible within all child classes in the hierarchy, use the <tt><b>private</b></tt> access modifier before the class name or class path to inherit as follows:
    @code{.py}
class ChildClass inherits private ParentClass {
}
    @endcode

    To inherit a class where the inherited class is only available to the inheriting class but not to child classes, use the <tt><b>private:internal</b></tt> access modifier before the class name or class path as follows:
    @code{.py}
class ChildClass inherits private:internal ParentClass {
}
    @endcode

    It is not legal to directly inherit the same class directly more than once; that is; it is not legal to list the same class more than once after the <tt><b>inherits</b></tt> keyword. However, it is possible that a base class could appear more than once in the inheritance tree if that class is inherited separately by two or more classes in the tree.

    In this case, the base class will actually only be inherited once in the subclass, even though it appears in the inheritance tree more than once. This must be taken into consideration when designing class hierarchies, particularly if base class constructor parameters for that class are explicitly provided in a different way by the inheriting classes.

    @note Class members only exist once for each object; therefore if classes in an inheritance tree have different uses for members with the same name, then a class hierarchy built of such classes will probably not function properly.

    Subclasses can give explicit arguments to their base class constructors using a special syntax (only available to subclass constructors) similar to the C++ syntax for the same purpose as follows:\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>[[<b>@ref private_methods "private[:internal|hierarchy]"</b>|<b>@ref public_methods "public"</b>] [<b>@ref deprecated "deprecated"</b>] <b>constructor</b>([</tt><em>@ref data_type_declarations "[param_type]"</em> <tt>$</tt><em>param_name</em> <tt>[=</tt> <em>@ref expressions "default_initialization_expression"</em><tt>], ...]) [: </tt><em>parent_class_name</em><tt>(</tt><em>args...</em><tt>), ...] {</tt>\n
    &nbsp;&nbsp;&nbsp;&nbsp;<tt>}]</tt>

    Here is a concrete example of giving arguments to an inherited base class:
    @code{.py}
class XmlRpcClient inherits Qore::HTTPClient {
    # calls the base class HTTPClient constructor, overrides the "protocols" key to "xmlrpc"
    constructor(hash opts = hash()) : Qore::HTTPClient(opts + ( "protocols" : "xmlrpc" )) {
    }
}
    @endcode

    Because base class constructors are executed before subclass constructors, the only local variables in the constructor that can be referenced are those declared in the subclass constructor declaration (if any). What this means is that if you declare local variables in the expressions giving base class arguments, these local variables are not accessible from the constructor body.

    @note Base classes that give explicit arguments to their base class constructors can be overridden by subclasses by simply listing the base class in the base class constructor list and providing new arguments.

    @subsection private_inheritance Private Inheritance

    Classes inherited using the <b><tt>private</tt></b> access modifier encapsulate the functionality (members, constants, methods, etc) of the parent class privately in the class hierarchy; that is, any access to the privately-inherited parent class's functionality from outside the class hierarchy will result in either a parse-time or runtime exception, depending on when the error is caught.  When inheritance is declared <tt><b>private</b></tt>, the inherted class is accessible in all child classes in the hierarchy.

    Classes inherited using the <tt><b>private:internal</b></tt> access modifier limit access to the inherited class to the child class; the inherited class in this case is not available in the rest of the class hierarchy but is limited to the directly inheriting child class.

    @subsection public_inheritance Public Inheritance

    Classes are inherited publically by default; public inheritance means that the parent class's functionality (members, constants, methods, etc) have the same visibility in the child class as they do in the parent class.  For example, a public method in the parent class will also be public in the child class if the parent class is inherited publically.  Respectively, private methods of publically-inherited parent classes will still be private in child classes.
*/
