Connecting Tech Pros Worldwide Help | Site Map

What's the usage?

  #1  
Old July 22nd, 2005, 10:01 AM
ikl
Guest
 
Posts: n/a
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!


  #2  
Old July 22nd, 2005, 10:01 AM
Mike Wahler
Guest
 
Posts: n/a

re: What's the usage?



"ikl" <ikl72@dsp.com> wrote in message
news:PMscc.26067$vo5.826762@bgtnsc05-news.ops.worldnet.att.net...[color=blue]
> What's the usage of #ifdef and #endif in the code below?
>
> #ifdef C_DEF[/color]

if the symbol 'C_DEF' is defined (with a #define directive),
then translate all the following code...
[color=blue]
> class C
> {
> public:
> void Repair();
> };
>
> void C::Repair () {
> ...
> }[/color]

.... until a
[color=blue]
> #endif[/color]

... directive is encountered.
[color=blue]
>
> Since I understand using like:
>
> #ifdef C_DEF
> class C
> {
> public:
> void Repair();
> };
> #endif[/color]

This is the same as above, except it doesn't
include the definition of the member function
'Repair()'.
[color=blue]
>
> void C::Repair () {[/color]

A class 'C' must be visible at this point for
this to be valid.
[color=blue]
> ...
> }[/color]


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

-Mike


  #3  
Old July 22nd, 2005, 10:01 AM
Mike Wahler
Guest
 
Posts: n/a

re: What's the usage?



"ikl" <ikl72@dsp.com> wrote in message
news:PMscc.26067$vo5.826762@bgtnsc05-news.ops.worldnet.att.net...[color=blue]
> What's the usage of #ifdef and #endif in the code below?
>
> #ifdef C_DEF[/color]

if the symbol 'C_DEF' is defined (with a #define directive),
then translate all the following code...
[color=blue]
> class C
> {
> public:
> void Repair();
> };
>
> void C::Repair () {
> ...
> }[/color]

.... until a
[color=blue]
> #endif[/color]

... directive is encountered.
[color=blue]
>
> Since I understand using like:
>
> #ifdef C_DEF
> class C
> {
> public:
> void Repair();
> };
> #endif[/color]

This is the same as above, except it doesn't
include the definition of the member function
'Repair()'.
[color=blue]
>
> void C::Repair () {[/color]

A class 'C' must be visible at this point for
this to be valid.
[color=blue]
> ...
> }[/color]


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

-Mike


  #4  
Old July 22nd, 2005, 10:01 AM
JaSeong Ju
Guest
 
Posts: n/a

re: What's the usage?


#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.

[color=blue]
> 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!
>
>[/color]

  #5  
Old July 22nd, 2005, 10:01 AM
JaSeong Ju
Guest
 
Posts: n/a

re: What's the usage?


#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.

[color=blue]
> 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!
>
>[/color]

  #6  
Old July 22nd, 2005, 10:03 AM
Kevin Goodsell
Guest
 
Posts: n/a

re: What's the usage?


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.
  #7  
Old July 22nd, 2005, 10:03 AM
Kevin Goodsell
Guest
 
Posts: n/a

re: What's the usage?


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.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU usage amd memory usage Sirisha answers 3 October 11th, 2006 11:15 AM
High Memory Usage Garbage Collection Question Ian Taite answers 3 November 22nd, 2005 10:14 PM
memory usage tomvr answers 2 November 22nd, 2005 09:48 AM
High Memory Usage Garbage Collection Question Ian Taite answers 3 July 24th, 2005 02:55 PM
memory usage tomvr answers 2 July 21st, 2005 02:05 PM