"Srini" <[EMAIL PROTECTED]> writes: > -- buffer.h -- > #ifndef _BUFFER_H_ > #define _BUFFER_H_
This means that your program, should it compile, has undefined behavior. Name starting with _[A-Z] are reserved to the C/C++ implementation. We mere users must not declare such names in our code. > #include "typedefs.h" > > // Place holder ONLY!! > #define BLOCK_SIZE 256 Even as a placeholder, I'd write enum { BLOCK_SIZE = 256 }; to make it behave. > class Buffer > { > public: > Buffer(); > Buffer(ULong fillPattern); > ~Buffer(); > > private: > UInt length; > char buf[BLOCK_SIZE]; // Need to define BLOCK_SIZE somewhere > appropriate > }; > > #endif > > > -- buffer.cpp -- > #include "buffer.h" > #include <cstring> > > using std::memcpy; > > #ifdef DEBUG > #include <iostream> #include <ostream> > #endif > > /*************** Construction & Destruction *************/ > > inline Buffer::Buffer() > : length(BLOCK_SIZE) > { } > > Buffer::Buffer(ULong fillPattern /*, UInt len */) > : length(BLOCK_SIZE /*len */) > { > for(int i = 0; i < length; i += sizeof(ULong)) > { > memcpy( buf+i , &fillPattern , sizeof(ULong) ); In general, this will write past the end of buf. > } > #ifdef DEBUG > for(int i = 0 ; i < 2*sizeof(ULong) ; i += 4) > { > ULong *tmp = reinterpret_cast<ULong *>(buf+i); In general, this will read past the end of buf. You may also run into alignment problems. _______________________________________________ Help-gplusplus mailing list Help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus