954,136 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ Macros - help please

I need help solving two macro questions in C++.
They are:

Define a macro PANIC that expands to code that uses cout to print the word PANIC and then calls a function quit (with no arguments).

I think the answer is

#define PANIC;
cout <

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

ur first question is somewhat confusing. but i give my idea.

#define PANIC (cout<<"panic";quit();))

the second question answer is:

#define PLUS1(x) (x+1)

still if u have any queries. write me to [email]bvvkrishna@rediffmail.com[/email]

bvvkrishna
Newbie Poster
4 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

That's incorrect. Can anybody else help?

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

Hi,
the first questions answer is

#define PANIC cout<<"panic \n"<

brnprasad630
Newbie Poster
6 posts since Aug 2004
Reputation Points: 11
Solved Threads: 0
 

When I run the first problem through the compiler, I get the message:

Wrong code assigned to PANIC. Check the function calls and don't forget semicolons.

On the second question, I get the error message:

It seems that you are lacking parentheses around the parameter supplied.

When I put a space between PLUS1 and (x), this message appears:

Wrong code assigned to PLUS1. Please revise.

Please help.

Thanks,
C++

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

I figured it out!!! The answers are:

#define PANIC cout<<"PANIC";quit();

and:

#define PLUS1(x) ((x)+1)

Thanks for your help anyway.

Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You