C++,Macro Problem

sdmahapatra's Avatar, Join Date: Jun 2009
Go4Expert Member
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.
sdmahapatra's Avatar, Join Date: Jun 2009
Go4Expert Member
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.
sdmahapatra's Avatar, Join Date: Jun 2009
Go4Expert Member
this has been solved