creating function.

how would i make a function which does something like
1. it takes in a value or it can not like test() works but also test(12) works.
2. if it receives a value than it stores it inside function. test(12) store 12
3. if it is just called then return stored value.

so like
test() // does not have to work since nothing is stored.
test(true) // store true
test() = true // return true
test(false) // store false
test() = false // return false
test() = false and so on. // return false
Last edited on
you must make the function like:

void test(int a, int &b)
{
// a is ur input
// b is returnes value
b = a;
}

like:

void test(int a, int &b);
int main()
{
int a, b;
cin >> a;
test(a, b);
cout <<b;
}

i think.
I found a way to solve my problem without using function.
thank you for help :)
Topic archived. No new replies allowed.