C++: name of a value may have linkage

81 views Asked by At

Extracted from cppreference.com:

A name that denotes object, reference, function, type, template, namespace, or value, may have linkage.

What is "the name of a value"? Can anybody provide an example where a name of a value is not a name of an object?

1

There are 1 answers

2
Arnav Borborah On

One example of something close to this would be an enum's values, although technically they are named constants:

enum class example
{
    ONE = 1,
    TWO
}

In this case, the enum example has names that are values where ONE corresponds to 1, and TWO corresponds to 2.

These aren't just variables since you can't assign to them.

Lastly, according to the link you posted, the enumerators have external linkage.