Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is the meaning of the footnote mentioned in [expr.ref]/1?

[expr.ref]/1:

A postfix expression followed by a dot . or an arrow ->, optionally followed by the keyword template (17.2), and then followed by an id-expression, is a postfix expression. The postfix expression before the dot or arrow is evaluated;67 the result of that evaluation, together with the id-expression, determines the result of the entire postfix expression.

67) If the class member access expression is evaluated, the subexpression evaluation happens even if the result is unnecessary to determine the value of the entire postfix expression, for example if the id-expression denotes a static member.

like image 528
Alexander Avatar asked Jun 13 '17 19:06

Alexander


People also ask

What is the meaning of footnotes?

Definition of footnote (Entry 1 of 2) 1 : a note of reference, explanation, or comment usually placed below the text on a printed page 2 a : one that is a relatively subordinate or minor part (as of an event, work, or field) a movement now regarded as a footnote to architectural history

What does the number “1” mean in a footnote?

This is an illustration of a footnote.1 The number “1” at the end of the previous sentence corresponds with the note below. See how it fits in the body of the text? 1 At the bottom of the page you can insert your comments about the sentence preceding the footnote.

What are footnotes in Apa 1?

1. What Are Footnotes? Footnotes are notes that are placed at the end of a page and used to reference parts of the text (generally using superscript numbers). Writers use footnotes for several purposes, including citations, parenthetical information, outside sources, copyright permissions, background information, and more.

When was the first known use of footnote used?

The first known use of footnote was in 1711. English Language Learners Definition of footnote. : someone or something that is remembered or regarded as a minor or unimportant part of an event, work, etc.


1 Answers

If a member is defined as static, then there is only one copy of that member for the class, not one copy for each instance of the class. Static members can be referenced via an instance (an object) of the class. The footnote clarifies that the expression identifying the instance is evaluated (and any side effects take place) even though you don't need to know which instance object you're accessing to know the value of the static member.

An example:

#include <iostream>

class foo {
    public:
        static int s;
};

int foo::s = 42;

int index() {
    std::cout << "index returns 5\n";
    return 5;
}

int main() {
    foo arr[10];
    std::cout << arr[index()].s << "\n";
}

There's only one s object, and its value is 42, but the expression arr[index()] is still evaluated, even though its result isn't needed to determine the value of s.

The output is:

index returns 5
42
like image 78
Keith Thompson Avatar answered Nov 06 '22 11:11

Keith Thompson