From: NG Chi Fai Newsgroups: comp.os.msdos.djgpp,comp.lang.c++ Subject: Help:program runs compiled with DJGPP but not CYGWIN Date: Sat, 22 May 1999 10:54:24 -0700 Organization: oronet, Penn Valley, C Lines: 86 Message-ID: <3746EF50.623D07F8@netvigator.com> NNTP-Posting-Host: gv2-210.oro.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 22 May 1999 17:55:07 GMT X-Mailer: Mozilla 4.51 [en] (Win95; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello, The following piece of code runs if compiled with DJGPP but not CYGWIN. If compiled with CYGWIN, it has error when executing the destructor. [main] C:\WINDOWS\DESKTOP\A.EXE 1007 (0) handle_exceptions: Exception: STATUS_ACCESS_VIOLATION Please help. Thanks in advance. best regards, NG Chi Fai #include template < class T > class a { private: public: // template < class U > friend class a; T* t; a(void) { t=new T[256]; }; template < class U > a(const a &v) { t=new T[256]; *this=v; }; ~a(void) { delete[] t; }; template < class U > a & operator = (const a &v) { int i; for(i=0;i<256;i++) { t[i]=T(v.t[i]); } return *this; }; void fill ( const T & h) { int i; for(i=0;i<256;i++) { t[i]=h; } }; a duplicate(void) { a temp; temp=*this; return temp; }; friend ostream & operator << (ostream& out, const a& t); }; template < class T > ostream& operator << (ostream& out, const a & t) { out << t.t[0]; for (int i=1;i<256;i++) out << ',' << t.t[i]; out << '\n'; return out; } int main(void) { a b; a c; a d; b.fill (99); c.fill (88.888); d=b; b=c; c.duplicate(); cout << b << c << d; return 0; }