By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

indipendent output

P: n/a
Hi,

I made a little program in C++, which initially displayed its data to the
standard output with the cout object. Now that I added a little graphic
interface with gtk+, I'd like to keep the class code as indipendent as
possible. This way, I could leave both version, graphic and not.

In the graphic version, every object would output its data to the
text_view object, while in the no-graphic version, it would output its
data to the standard output with cout. How can I do this ?

Any suggestions?

Thanks in advance
Salvo
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
salvo wrote:
Hi,

I made a little program in C++, which initially displayed its data to the
standard output with the cout object. Now that I added a little graphic
interface with gtk+, I'd like to keep the class code as indipendent as
possible. This way, I could leave both version, graphic and not.

In the graphic version, every object would output its data to the
text_view object, while in the no-graphic version, it would output its
data to the standard output with cout. How can I do this ?

Any suggestions?

Thanks in advance
Salvo


Yes, derive a class from streambuf which will write
to the UI. An instance of this class can be passed
around wherever an ostream class is required.

Read the FAQs and welcome.txt for guidelines. Also
search the web for Dietmar Kuhl, who is an expert
in this area. His website contains an example of
creating a specialized stream class.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 23 '05 #2

P: n/a
> Yes, derive a class from streambuf which will write
to the UI. An instance of this class can be passed
around wherever an ostream class is required.

Read the FAQs and welcome.txt for guidelines. Also
search the web for Dietmar Kuhl, who is an expert
in this area. His website contains an example of
creating a specialized stream class.


Thank you! It seems to be exactly what I needed.

Salvo

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.