471,585 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

What's the usage?

ikl
What's the usage of #ifdef and #endif in the code below?

#ifdef C_DEF
class C
{
public:
void Repair();
};

void C::Repair () {
....
}
#endif

Since I understand using like:

#ifdef C_DEF
class C
{
public:
void Repair();
};
#endif

void C::Repair () {
....
}
Thanks!
Jul 22 '05 #1
6 1493

"ikl" <ik***@dsp.com> wrote in message
news:PM********************@bgtnsc05-news.ops.worldnet.att.net...
What's the usage of #ifdef and #endif in the code below?

#ifdef C_DEF
if the symbol 'C_DEF' is defined (with a #define directive),
then translate all the following code...
class C
{
public:
void Repair();
};

void C::Repair () {
...
}
.... until a
#endif
... directive is encountered.

Since I understand using like:

#ifdef C_DEF
class C
{
public:
void Repair();
};
#endif
This is the same as above, except it doesn't
include the definition of the member function
'Repair()'.

void C::Repair () {
A class 'C' must be visible at this point for
this to be valid.
...
}

Look up 'preprocessor directives' in your C++ book.

-Mike
Jul 22 '05 #2

"ikl" <ik***@dsp.com> wrote in message
news:PM********************@bgtnsc05-news.ops.worldnet.att.net...
What's the usage of #ifdef and #endif in the code below?

#ifdef C_DEF
if the symbol 'C_DEF' is defined (with a #define directive),
then translate all the following code...
class C
{
public:
void Repair();
};

void C::Repair () {
...
}
.... until a
#endif
... directive is encountered.

Since I understand using like:

#ifdef C_DEF
class C
{
public:
void Repair();
};
#endif
This is the same as above, except it doesn't
include the definition of the member function
'Repair()'.

void C::Repair () {
A class 'C' must be visible at this point for
this to be valid.
...
}

Look up 'preprocessor directives' in your C++ book.

-Mike
Jul 22 '05 #3
#ifdef and #endif are used for conditional compilation.
If C_DEF is defined, then compile in the class C and its
public member functions.

If C_DEF is not defined, then class C is
not included. Then of course you dont want to include
the
void C::Repair () {
....
}
member function, since its an error.

What's the usage of #ifdef and #endif in the code below?

#ifdef C_DEF
class C
{
public:
void Repair();
};

void C::Repair () {
...
}
#endif

Since I understand using like:

#ifdef C_DEF
class C
{
public:
void Repair();
};
#endif

void C::Repair () {
...
}
Thanks!


Jul 22 '05 #4
#ifdef and #endif are used for conditional compilation.
If C_DEF is defined, then compile in the class C and its
public member functions.

If C_DEF is not defined, then class C is
not included. Then of course you dont want to include
the
void C::Repair () {
....
}
member function, since its an error.

What's the usage of #ifdef and #endif in the code below?

#ifdef C_DEF
class C
{
public:
void Repair();
};

void C::Repair () {
...
}
#endif

Since I understand using like:

#ifdef C_DEF
class C
{
public:
void Repair();
};
#endif

void C::Repair () {
...
}
Thanks!


Jul 22 '05 #5
JaSeong Ju wrote:
<A top-posted message.>

Please stop top-posting. Read section 5 of the FAQ (which you should
have already read) for posting guidelines:

http://www.parashift.com/c++-faq-lite/

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #6
JaSeong Ju wrote:
<A top-posted message.>

Please stop top-posting. Read section 5 of the FAQ (which you should
have already read) for posting guidelines:

http://www.parashift.com/c++-faq-lite/

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jonathan Fine | last post: by
5 posts views Thread by John Smith | last post: by
669 posts views Thread by Xah Lee | last post: by
7 posts views Thread by Leonel Gayard | last post: by
10 posts views Thread by rdemyan via AccessMonster.com | last post: by
3 posts views Thread by Sirisha | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.