File: cvscpp.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (48 lines) | stat: -rw-r--r-- 1,428 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
In this section we'll discuss an important difference between bf(C) and
bf(C++) structs and (member) functions. In bf(C) it is common to define
several functions to process a tt(struct), which then require a pointer to the
tt(struct) as one of their arguments. An imaginary bf(C) header file showing
this concept is:
        verb(    /* definition of a struct PERSON    This is C   */
    typedef struct
    {
        char name[80];
        char address[80];
    } PERSON;

    /* some functions to manipulate PERSON structs */

    /* initialize fields with a name and address    */
    void initialize(PERSON *p, char const *nm,
                       char const *adr);

    /* print information    */
    void print(PERSON const *p);

    /* etc..    */)

In bf(C++), the declarations of the involved functions are put inside
the definition of the tt(struct) or tt(class). The argument denoting
which tt(struct) is involved is no longer needed.
        verb(    class Person
    {
        char d_name[80];
        char d_address[80];

        public:
            void initialize(char const *nm, char const *adr);
            void print();
            // etc..
    };)

In bf(C++) the tt(struct) parameter is not used. A bf(C) function call
such as:
        verb(    PERSON x;

    initialize(&x, "some name", "some address");)

becomes in bf(C++):
        verb(    Person x;

    x.initialize("some name", "some address");)