Attributes of Objects

Attributes of Objects - Chirag Patel January 01, 2009

type
- Determines size of object and its memory address alignment
- the values the object can have
- the operations that can be performed on the object
- a function type specifies function parameter lists and return type

scope
- portion of translation unit (source code produced by preprocessor from source and header files) in which the name is visible
- file scope, block scope, function prototype scope, function scope
- C++ has namespace scope and class scope in addition

storage duration
- lifetime of the storage of object
- static, automatic or dynamic
- enumeration constants, functions, labels, types - do not have storage duration

linkage
- no linkage => entity can’t be referenced via name from anywhere else
- internal linkage => entity that can be referenced via name declared in the same scope or in other scopes of the same translation unit
- external linkage => in addition to capabilities similar to internal linkage, this can be referenced in other translation units

keywords: auto, extern, register, static - defines storage duration and/or linkage

Posted under c++

This post was written by Chirag on January 2, 2009