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?

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

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

ok,
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;
public:
  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;
  }
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.