C++,Macro Problem

Go4Expert Member
21Jun2009,13:59   #1
sdmahapatra's Avatar
Quote:
I've written below simple code.Actually need to do that the value which is given by an user that will use as macro and macro value will automatically initialyzed to all needed place.Not to given every time.
Code:

#include<iostream>
#include"conio.h"
#define AB def()
int main(int argc, char* argv)
{
int a=3,b=2;
int def();
int add(int,int);
int sub();
std::cout << "\nAddition Result :" << add(a,b);
std::cout << "\nSubtraction Result :" << sub();
_getch();
//std::cin.get();
//system("pause");
return 0;
}
int def()
{
int m;
std::cout << "\nEnter The Value Of Def :";
std::cin >> m;
return m;
}
int add(int x,int y)
{
return (AB+x+y);
}
int sub()
{int v;
std::cout << "\nEnter The Value Of v :";
std::cin >> v;
int n=(AB-v);
return (n);
}
Quote:
So,please any C/C++ expert please help me out from this problem.Thanks a lot.
Go4Expert Member
21Jun2009,17:15   #2
sdmahapatra's Avatar
I am coding a big program and this macro concept is needed to use there.This program is only to clear my doubt.I want once I've giving the value of def which keep stored in m.Second time the value of m automatically taken by
Code:
int sub()
function.Once I given the value of def,I don't want to give it again through the program.
Go4Expert Member
17Jul2009,00:11   #3
sdmahapatra's Avatar
this has been solved