C++Non-Static Member Functions

Download C++ for free

Syntax

  • // Calling:

    • variable.member_function();
    • variable_pointer->member_function();
  • // Definition:

    • ret_type class_name::member_function() cv-qualifiers {
      • body;
    • }
  • // Prototype:

    • class class_name {
      • virt-specifier ret_type member_function() cv-qualifiers virt-specifier-seq;
      • // virt-specifier: "virtual", if applicable.
      • // cv-qualifiers: "const" and/or "volatile", if applicable.
      • // virt-specifier-seq: "override" and/or "final", if applicable.
    • }

Remarks

A non-static member function is a class/struct/union member function, which is called on a particular instance, and operates on said instance. Unlike static member functions, it cannot be called without specifying an instance.

For information on classes, structures, and unions, please see the parent topic.

Related Examples

Non-static Member Functions