Error message

  • Deprecated function: Return type of DatabaseStatementBase::execute($args = [], $options = []) should either be compatible with PDOStatement::execute(?array $params = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2244 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in drupal_random_bytes() (line 2268 of /home2/psicolog/public_html/feliponcho/includes/bootstrap.inc).
  • Deprecated function: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in url() (line 2349 of /home2/psicolog/public_html/feliponcho/includes/common.inc).
  • Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in url_is_external() (line 2393 of /home2/psicolog/public_html/feliponcho/includes/common.inc).
  • Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in url_is_external() (line 2395 of /home2/psicolog/public_html/feliponcho/includes/common.inc).
  • Deprecated function: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in url() (line 2311 of /home2/psicolog/public_html/feliponcho/includes/common.inc).

Inheritance and Access Control

Index



Base Class Access Control

  • Public
    • Public remain public
    • Private remain private
    • Protected remain protected
  • Protected
    • Protected members are inherited as private members
  • Class derivation access is private by default when using class keyword. This means that if access_specifier is not defined, then it is private by default.
    class DerivedClass:access_specifier base_class{
    };
    
  • In order to make a public derivation of a base class, public should be defined:
    class Car:public Vehicle{
    };
    
  • Also you may use struct keyword to define a class. The funny thing about doing this is that all that is private by default when using class keyword, is public when using struct keyword.
  • Even funnier!, you may use union keyword to define a class :D. This is interesting because only one member of the class can be used at a time, and also as in classic unions, the bigger member will define the size of the class in memory.




    Ways of Inheritance

  • Public Inheritance
    • Specified between two classes as:
      class Car:public Vehicle
    • Base class Private members
      • manipulate through inherited member functions
      • not accessible directly
      • still inherited
    • Base class Public and Protected members
      • inherited with original member access
    • friend functions not inherited
  • Protected Inheritance
    • Specified between two classes as:
      class Car:protected Vehicle
    • Base class Private members
      • same as public inheritance
    • Base class Protected members
      • retain the protected feature in the derived class
    • Base class Public members
      • becomes protected in the derived class
    • friend functions not inherited
  • Private Inheritance
    • Specified between two classes as:
      class Car:private Vehicle
      class Car: Vehicle
    • Base class Private members
      • same as public inheritance
    • Base class Protected and Public members
      • becomes private in the derived class
    • friend functions not inherited




    Access Mechanism in Classes






    Effects of Inheritance on Members Visibility






    Member Access in Base Class

    private protected public

    Always inaccessible regardless of derivation access

    Private in derived class if you use private derivation

    Private in derived class if you use private derivation

    Protected in derived class if you use protected derivation

    Protected in derived class if you use protected derivation

    Protected in derived class if you use public derivation

    Public in derived class if you use public derivation




    Multiple Multilevel Inheritance

  • This is one of my favorite examples of inheritance in C++, this shows how powerful inheritance perspective is in this language for SW design.
  • Consider the case of processing the student results where weighting have to be given for sports before finalizing the results. The weighting for sports is stored in a separate class called sports. The inheritance between the various classes is:






    Inheritance Summary






    Multipath Inheritance Ambiguity