mardi 26 juillet 2016

Printing the values of an instantiated structure without using the names of the fields in C++

Can I do it?

For example consider the following structure:

struct bag {
     string fruit;
     string book;
     string money;
};

I want to print the values of the fields of an instance of the structure bag in a sequentially form and obtain an output like this:

apple
Computer Networking, A top-down Approach
100

But without using the names of the fields(fruit, book and money). Any help would be appreciated. The only information I know it is that all the fields are C++ strings.

Aucun commentaire:

Enregistrer un commentaire