Topic: bug bug Borland C++, strstream constructor


Author: Zijian Huang <zijian.huang@ncl.ac.uk>
Date: 10 Mar 1995 22:58:50 GMT
Raw View
I wrote some program in Borland C++ 4.0

about strstream

see the program below:

class mo
{
  unsigned char buffer[80];
  strstream source;
.........
}

mo::mo(.......) : source(buffer, 80) .....
{
......
}

then the program pass the compiler, and the first link, in the second link,
BCC say:
'Error: undefine symbol mo::strstream(unsigned char _FAR *, int, int) .....'

then I check Borlandc enviroment,
from strstrea.h

class _EXPCLASS strstream : public strstreambase, public iostream {
public:
        _RTLENTRY strstream();
        _RTLENTRY strstream(         char _FAR *, int _sz, int _m);
        _RTLENTRY strstream(signed   char _FAR *, int _sz, int _m);
        _RTLENTRY strstream(unsigned char _FAR *, int _sz, int _m);
        _RTLENTRY ~strstream();

    char _FAR * _RTLENTRY str();
};

from help:

Description

Provides simultaneous input and output to and from an array using a strstreambuf.
Input and output is initiated using the functions of the base classes istream and ostream.
For example, strstream can use the function istream::getline() to extract characters from
the buffer.

Constructors

strstream();

Makes a strstream with the base class strstreambase's streambuf data member's buffer
dynamically allocated the first time it is used.  The put area and get areas are the same.

strstream(char*, int sz, int mode);

Makes a strstream with a specified n-byte buffer. If mode is ios::app or ios::ate, the
get/put
pointer is positioned at  the null character of the string.

strstream(signed char*, int sz, int mode);

Makes a strstream with a specified n-byte buffer. If mode is ios::app or ios::ate, the
get/put
pointer is positioned at  the null character of the string.

strstream(unsigned char*, int sz, int mode);

Makes a strstream with a specified n-byte buffer. If mode is ios::app or ios::ate, the
get/put
pointer is positioned at  the null character of the string.

Member Functions

char *str();


then I modify the program:

class mo
{
  char buffer[80];
  strstream source;
.........
}

then pass the second link, no problem

Why? bug bug Borland C++ 4.0? Could drive any programmer into crazy.
Who could explan it?
Thank Who.




Author: Edward Diener <70304.2632@CompuServe.COM>
Date: 11 Mar 1995 19:24:04 GMT
Raw View
In your constructor to the 'source' member variable you forgot
the third int parameter which is a mode parameter.