Problem with std::ostream, std::streambuf and "virtual xsputn"

Discussion in 'C++' started by Johannes Barop, Dec 29, 2005.

  1. Hello,

    i try to implement a streambuffer. I overwrote streambuf::eek:verflow() and
    streambuf::xsputn(). Both are protected and virtual
    (http://www.cplusplus.com/ref/iostream/streambuf/).

    But somehow my OutBuf::xsputn() is not beeing used. But the orginal
    basic_streambuf::xsputn() calls my OutBuf::eek:verflow().

    http://pastebin.com/483016 - OutBuf.h
    http://pastebin.com/483018 - OutBuf.cpp
    http://pastebin.com/483022 - gdb - Output

    Why basic_streambuf::xsputn() is called instead of OutBuf::xsputn() ?


    --
    Johannes B.
     
    Johannes Barop, Dec 29, 2005
    #1
    1. Advertising

  2. Johannes Barop wrote:
    > Hello,
    >
    > i try to implement a streambuffer. I overwrote streambuf::eek:verflow() and
    > streambuf::xsputn(). Both are protected and virtual
    > (http://www.cplusplus.com/ref/iostream/streambuf/).
    >
    > But somehow my OutBuf::xsputn() is not beeing used. But the orginal
    > basic_streambuf::xsputn() calls my OutBuf::eek:verflow().
    >
    > http://pastebin.com/483016 - OutBuf.h
    > http://pastebin.com/483018 - OutBuf.cpp
    > http://pastebin.com/483022 - gdb - Output
    >
    > Why basic_streambuf::xsputn() is called instead of OutBuf::xsputn() ?



    Most likely, the reason is that the signature of your overloaded class'
    m,ethod does not exactly match the signature of the base class' method.
     
    JH Trauntvein, Dec 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Jansson
    Replies:
    1
    Views:
    512
    David Rubin
    Nov 8, 2004
  2. Christopher Pisz
    Replies:
    2
    Views:
    603
    James Kanze
    Dec 12, 2007
  3. Replies:
    2
    Views:
    1,912
  4. Pallav singh
    Replies:
    3
    Views:
    4,054
    Saeed Amrollahi
    Oct 21, 2009
  5. , India
    Replies:
    3
    Views:
    2,873
    James Kanze
    Nov 13, 2010
Loading...

Share This Page