ABu
ABu

Reputation: 12299

C++: name of a value may have linkage

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?

Upvotes: 4

Views: 80

Answers (1)

Arnav Borborah
Arnav Borborah

Reputation: 11787

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.

Upvotes: 0

Related Questions