in this code:
would it be posssible to use n as an integer in afunction()?Code:#define something(n) afunction()
in this code:
would it be posssible to use n as an integer in afunction()?Code:#define something(n) afunction()
"Computers aren't intelligent, they only think they are."
**infected by Blizzarddog**
I am a signature virus. Please add me to your signature so that I may multiply
yes
macros do little more than replace code.
So,
#define something(n) afunction(n)
causes:
something(i);
to be the same as
afunction(i);
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
in that case could you tell me what i am doing wrong here?
Code:#include <iostream> #include <conio.h> using namespace std; #define something(n) funct() void funct(void) { cout<<n; } int main() { something(1); getch(); return 0; }
"Computers aren't intelligent, they only think they are."
**infected by Blizzarddog**
I am a signature virus. Please add me to your signature so that I may multiply
yes, your "funct()" does not take a parameter n. Why are you using a macro for this anyway?
ie:
void funct(int n).....
In addition, your macro doesn't pass it in to funct as my previous example shows
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
ok thanks that worked, i didnt finish reading your post (not too bright today)
>Why are you using a macro for this anyway?
i was trying to think of a simple example as it would be easier to not have to read through lines of unrelated code
"Computers aren't intelligent, they only think they are."
**infected by Blizzarddog**
I am a signature virus. Please add me to your signature so that I may multiply