Hi All,
I below code snippet I have been using diff-2 structure with same variable due to having different -2 default values
for the variable (var) in current implementation for both the structure a and b. This way i need to create 17 structure with same variable (var) but different default values.
Could you let me know what is the best way to achieve the same with having same sturcture with different-2 values.
Apart from this it is very much required to initialize the varaible (var) with default value in structure as it shouldn't be uninitialized.
#include <iostream>
using namespace std;
struct a
{
int var;
a()
{
var=0;
}
};
struct b
{ int var;
b()
{
var=12;
}
};
void test(a& obj);
void test( b& obj1);
int main() {
a obj;
b obj1;
test(obj);
test(obj1);
//test(a, b);
return 0;
}
void test( a& obj)
{int avar;
avar=obj.var;
cout<<avar;
}
void test( b& obj1)
{int bvar;
bvar=obj1.var;
cout<<bvar;
}