[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] / [Samples] / c++.glossary
[Index] [Contents] [Source Text] [About] [Notation] [Copyright] [Comment/Contact] [Search ]
Sun Nov 2 09:14:39 PST 2008


    C++ Glossary

      Source: Based on the comp.lang.c++.FAQ

      Meta-linguistic terms

    1. ctor::=constructor.
    2. mem::=member::=a component of an object of a given class.
    3. copy-ctor::=copy constructor (declared 'X(const X&)' and pronounced X-X-ref')`.
    4. dtor::=destructor.
    5. fn::=function.
    6. fns::=functions.
    7. ptr::=pointer::=a C/C++ construct declared by: int * p;.
    8. ref::=reference::=a C++ construct declared by: int & r;.
    9. OO::=object_oriented.
    10. OOP::=object-oriented programming.
    11. OOPL::=object-oriented programming language.
    12. method::=member function.


      Source: Annotated Ref Manual C1990 Page 7

    13. preprocessor_tokens::= hash | double_hash.
    14. hash::lexeme= "#", flags a preprocessor directive like include and define.
    15. double_hash::lexeme= "##", used in a preprocessor directive to separate tokens that need to be together.

    16. keyword::="asm" | "auto" | "break" | "case" | "char" | "class" | "const" | "continue" | "default" | "delete" | "do" | "double" | "else" | "enum" | "extern" | "float" | "for" | "friend" | "goto" | "if" | "inline" | "int" | "long" | "new" | " operator" | "private" | "protected" | "public" | "register" | "return" | "short" | "signed" | "sizeof" | "static" | "struct" | "switch" | "template" | "this" | "throw" | "typedef" | "union" | "unsigned" | "virtual" | "void" | "volatile" | "while".

    17. punctuation::= "(" | "{" | "[" | "]" | "}" | ")" | ";" | ":" | "?" | "\"" | "," | "." .

    18. operators::= "!" | "%" | "^" | "&" | "*" | "-" | "+" | "=" | "|" | "~" | "<" | ">" | "/" | "->" | "++" | ".*" | "->*" | "<<" | ">>" | "<=" | ">=" | "==" | "!=" | "||" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "|=" | "::".

    19. identifier::= #identifier_character ~ keyword & not starting with a "_" or containing "__".

    20. identifier_character::= "a".."z" | "A".."Z" | "0".."9" | "_".

      Meanings of keywords

    21. case::keyword=indicates the start of case in a switch statement.

    22. const::keyword=following,
      1. If a varible is declared to be const then its value may not be changed.
      2. If an argument is specified to be const then its value can not be changed.
      3. If a member function is declared const
         		Type name(arguments) const
        then it will not change the state of the object and can be safely applied to const arguments and variables of the type.

      (End of Net)

    23. for::keyword=`indicates the start of a for loop.
       		for(i=0; i<10; i++) ...
       		for(i=10; i>=0; i--) ...
       		for(i=0,j=10; i<10; i++,j--) ...
    24. for(A;B;C)D means the same as
    25. { A; while(B){ {D} C; }}

    26. static::keyword=following
      • Inside a class, a member is labeled static if belongs to the class rather than an object in the class. Such static members are shared by all objects.
      • Inside a function a static variable is one that has its storage allocated by the link-loader before the program starts running and deallocated when the program stops. However it is only accessible in statements inside the function. It's value is preserved between calls to the function.
      • Outside a class and function a static identifier is one that can be used anywhere in the file but by nothing outside the file. Here static acts gives a degree of privacy at the file level to functions, variables, classes etc.

    27. switch::keyword=start of a switch statement,
       		case 2: i=3; break;
       		case 3: i=2; break;

    28. virtual::keyword=following,
      • If a member function f of class B is defined to be virtual and a B* variable v is pointing at an object of derived class D then a call
        will call the version of f defined in D (if any) rather than B. In short this use of virtual indicates dynamic dispatching.
      • If class D is derived from two classes X and Y and both X and Y are derived from B, then the word virtual indicates that only one "copy" of B will be present in D.

    29. void::keyword=following
      1. 'void' and 'void *' in C and C++ are kludges.
      2. The philosophy of C was that all subprograms are mathematical functions like sin, cos, and sqrt.
      3. However C functions also do things(printf, scanf) and some them do not calculate any thing sensible(fclose() is an example). In K&R C it returned a random int that the program was expected to ignore. The function was declared as an int fclose(). Further, in K&R C the default type returned by a function that declared no type was int.
      4. Void was added to C when it evolved into ANSI C as a way to make clear that some function returned integers that means something (but which you might ignore if you wanted to -- like printf and scanf), and other functions did not return a value that made sense, and you absolutely should ignore the value.
      5. A subprogram that returns no value should be called a procedure. However the C tradition is to talk about 'void functions'.
      6. Here are some uses of void.

        • In C if you don't specify the type of a returned value it is assumed to be an int. An undefined and meaningless integer was left behind if no value is explicitly returned. The word void is used to document such a function. So void is not a type of data in this usage, but indicates the absence of data. Thus a C void function has no return values and can not be called in an expression.

        • In ANSI C, a function with no arguments has a prototype like this:
                   type f1(void);
          The compiler will not permit you to give f 1 any arguments. However
                   type f2();
          lets you put in any arguments you like....even if the result is rubbish.

          Note. In C++, the above use of void is obsolete

           	type f2();
          indicates that no arguments are allowed and
           	type f2(...);
          that no checking takes place at all. Note:
                   type f3(arg1, arg2, ...);
          expects 2 or more arguments.

      7. In ANSI C and C++ the lexeme void* also appears and means something quite different to plain void. Plain void indicates the absence of data. void* indicates the address of some data of unknown type. It is only used for formal arguments of functions. Thus functions can be written to use any type of data. An example is qsort in the standard C library. But a void* points at objects of unknown size, so pointer arithmetic is not defined on them. So void* arguments can not have subscripts and the * operator is undefined on them! Instead the size of the data is put in a different argument and, internally, the void* pointer is cast into a char* and all access to the objects is done using the explicit size and memory copy functions.

        Note. In C++ the use of 'void*' for addresses of objects of an unknown type is still legal. It is nearly always better to use polymorphism or templates instead. Templates let the compiler generate the right code to handle the particular data that is being processed. Polymorphism (inheritance+virtual functions) delays the choice of operation until the function is called.

      (End of Net)

    30. while::keyword=indicates the start of a while loop statement.
       		while(x<27){ x+=2; }

    . . . . . . . . . ( end of section C++ Glossary) <<Contents | End>>