How do I meet below objective in C++ language. My objective is to have an input source (a structure) defined in a constructor (or another method of same class) and access it in another method for processing. For Eg:
#include "iostream"
class A
{
public:
struct source{ //input source
char* input;
unsigned int result;
};
A(); //constructor
~A(); //destructor
void process();
};
A::A()
{
//static local input source
static const source inp[2] = { {"input1", 2}, {"input2", 3} };
}
void A::process()
{
//The value of static structure "inp" initialized in constructor is to be
// read here.
// Say I want to print the "result"
std::cout << "input1 result" << inp[0].result; //should print 2
std::cout << "input2 result" << inp[1].result; //should print 3
}
Any alternate approach meeting above objective is most welcome. Thanks in advance for the help.