C++11 example of a value and an object in the standard library?

前端 未结 3 770
栀梦
栀梦 2021-01-13 06:11

In C++11 3p3 it states:

An entity is a value, object, reference, function, enumerator, type, class member, template,

3条回答
  •  清酒与你
    2021-01-13 07:04

    The C++ standard does not provide a definition for 'value', relying on its ordinary English meaning. It defines 'object' as a 'region of storage'.

    The C++ standard library provides many values that are not objects. A simple example is NULL. Others include SIZE_MAX, EXIT_SUCCESS and FE_OVERFLOW. You may quibble over whether they are 'defined', since little explanation is provided in the standard.

    The C++ standard library provides few definitions of objects that I can find, in the sense of a name for a 'region of storage'. The only ones I know of (courtesy of a commenter) are the 'standard iostream objects' such as cin and cout.

    Since it includes the C standard library, another obvious one is errno, although even this includes a quibble that 'errno may not be the identifier of an object'.

    The standard libary does provide a large number of functions that return a pointer to an object on execution, new and malloc() being obvious examples. So it defines many dynamic objects, if you like.

    [edited to include iostream objects, new]

提交回复
热议问题