I have a structure
typedef struct A
{
int a;
int b;
char * c;
}aA;
I want to iterate over each an every member of the structure
You can't iterate over an object's data members. You can use std::ostream's stream insertion operator to print individually however:
struct A
{
int a;
int b;
std::string c;
friend std::ostream& operator <<(std::ostream& os, A const& a)
{
return os << a.a << '\n'
<< a.b << '\n'
<< a.c << '\n';
}
};
And inside main:
int main()
{
A a = {5, 10, "apple sauce"};
std::cout << a;
}
Output:
5
10
apple sauce
Here is a demo.