i keep some formatting data in an array of structs. it is a very long array. is it better to keep this information in another class and inherit from this class or is it better to not inherit from this class but create an instance of that class and use it in the other class. Finally, how about this: just hard code that array in the constructor of my consumer class?

8 Years
Discussion Span
Last Post by Narue

Can you be more specific about what you're trying to do and why?

i have three classes, one reads data from the database, the other one contains the functions to create xml nodes and elements and write them to a file, and the last one, gets the data from the reader and send it to xml writer class to create final output. now, the problem is the database representation of the data is different from what i like to see in the output file, so i need some formatting, that information is kept in one array of structs, the struct fields tell how it will appear on the final document. that formatting information can be a class it self, or it can be hardcoded somewhere in the operating class. which approach is better?


Perhaps a stream manipulator might make the most sense:

class xml_format {
  xml_data _data;
  vector<format_info> _info;
  xml_format ( const xml_data& data, const vector<format_info>& info )
    : _data ( data ), _info ( info )

  friend ostream& operator<< ( ostream& out, const xml_format& fmt )
    // Write the formatted data
    return out;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.