> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C++ Pointer-to-Member of Object

The `.*` operator is the C++ pointer-to-member access operator used to bind a pointer-to-member to a specific object instance. It evaluates to the actual member (data or function) of the left-hand object designated by the right-hand pointer-to-member.

```cpp theme={"dark"}
object.*pointer_to_member
```

## Operands and Type Requirements

* **Left Operand:** Must be an object of class type `T` (or a class derived from `T`, provided `T` is an unambiguous and accessible base class of the derived class). It can be an lvalue or an rvalue.
* **Right Operand:** Must be a pointer-to-member of class `T`. It cannot be a standard pointer; it must be declared using the `Type T::*` syntax.

## Pointer-to-Data-Member Mechanics

When the right operand is a pointer to a data member, the `.*` operator computes the memory offset of that member relative to the base address of the left operand.

The value category of the result depends on the left operand:

* If the object is an lvalue, the result is an lvalue.
* If the object is an rvalue, the result is an xvalue (expiring value).
* The cv-qualification (const/volatile) of the result is the union of the cv-qualifiers of the left operand and the type pointed to by the pointer-to-member. Because a pointer-to-member does not retain the `mutable` property of a data member, accessing a `mutable` member of a `const` object via `.*` yields a `const` result (unlike direct `.` member access).

```cpp theme={"dark"}
struct Entity {
    int x;
};

int Entity::* member_ptr = &Entity::x;

Entity obj;
obj.*member_ptr = 10; // Evaluates to an lvalue of type int designating obj.x
```

## Pointer-to-Member-Function Mechanics

When the right operand is a pointer to a member function, the `.*` operator yields a special, un-nameable bound member function entity.

This entity has strict syntactic limitations: it **must** be immediately invoked using the function call operator `()`. It cannot be assigned to a variable, cast, or passed as an argument.

Because the function call operator `()` has higher precedence than the `.*` operator, the entire `.*` expression must be enclosed in parentheses.

```cpp theme={"dark"}
struct Entity {
    void execute(int val) {}
};

void (Entity::* func_ptr)(int) = &Entity::execute;

Entity obj;
(obj.*func_ptr)(42); // Parentheses around (obj.*func_ptr) are mandatory
```

## Operator Characteristics

* **Precedence:** The `.*` operator has a precedence level of 4, which is lower than the member access operator `.` and the function call operator `()`, but higher than multiplication `*`.
* **Associativity:** Left-to-right.
* **Overloadability:** The `.*` operator **cannot** be overloaded. This guarantees that its semantics regarding offset calculation and member binding remain strictly defined by the compiler. (Note: Its counterpart, `->*`, can be overloaded).
* **Polymorphism:** If the right operand points to a virtual member function, the `.*` operator respects dynamic dispatch. The actual function invoked will be resolved at runtime based on the dynamic type of the left operand.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C++ Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
