#if, #ifdef #ifndef , . , , .
#if:
#if _
...
[ #elif _
...]
[ #elif _
...]
[# else
...]
#endif
#elif . , .
#if 0 //
int i, j;
double x,y;
#endif
#ifdef #ifndef , , #define ( ).
#ifndef , ( - ):
#ifndef HEADER_INCLUDED
# include "myheader.h"
#define HEADER_INCLUDED
#endif
#undef
.
++ , ,
_DATE_ − .
_FILE_ − .
_LINE_ − .
_TIME_ − .
printf(" -%s\n", _DATE_);
, . : , , , , .
. , , . , − , − . .
. , , , .
. , , . .
. , ( ), .
. , ( ) .
. ++ namespace.
. − , . , :
|
|
struct Node {
int Node;
int i;
} Node;
, , . ++ , :
- , , , , ;
- , , ;
- , ;
- .
. , , static.
, :
- ;
- extern.
− () .
. one.cpp two.cpp .
// my_header.h
extern int a;
extern double b;
...
____________
// one.cpp
#include "my_header.h"
int a;
...
____________
// two.cpp
#include "my_header.h"
double b;
...
____________
one.cpp two.cpp.
static, , .
, .. , , . , .
. , . , , , . - . .
:
namespace [_] {/**/}
, . , .
, , . static. , . .
namespace demo {
int i=1;
int k=0;
void func1(int);
void func2(int) {/*...*/}
}
namespace demo { //
|
|
// int i=2; // −
void func2(int); //
, . , ::, :
void demo::func1(int) {/*...*/}
, , . , :
demo:: int i=100; demo:: func2(10);
, using:
using demo::i;
.
- , using namespace:
using namespace demo;
using using namespace , :
namespace dam {
using demo:: i;
...
}
( , . .) .
1. .. / C++. / .. . , 2002.
2. .. / C++. : / .., .. . , 2002.
3. .. / C++. - : / .., ... , 2002.
4. .. ++ Builder./ ... , 2004.
.. 3
... 3
.. 3
. 5
. 5
.. 6
. 7
. 10
... 11
.. 11
.. 14
... 15
/. 15
. 15
/. 16
. 20
. 20
.. 22
.. 25
... 28
#include. 28
#define. 29
.. 30
#undef. 31
.. 31
... 31
. 33
.. 34
.. 37
++