in this code:
would it be posssible to use n as an integer in afunction()?Code:#define something(n) afunction()
Printable View
in this code:
would it be posssible to use n as an integer in afunction()?Code:#define something(n) afunction()
yes
macros do little more than replace code.
So,
#define something(n) afunction(n)
causes:
something(i);
to be the same as
afunction(i);
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;
}
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
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