Mail Archives: djgpp/1999/05/22/14:45:28
From: | NG Chi Fai <cfng1 AT netvigator DOT com>
|
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
|
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 <iostream.h>
template < class T >
class a
{
private:
public:
// template < class U > friend class a<U>;
T* t;
a(void)
{
t=new T[256];
};
template < class U > a(const a<U> &v)
{
t=new T[256];
*this=v;
};
~a(void)
{
delete[] t;
};
template < class U > a<T> & operator = (const a<U> &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<T> duplicate(void)
{
a<T> temp;
temp=*this;
return temp;
};
friend ostream & operator << <T> (ostream& out, const a<T>& t);
};
template < class T >
ostream& operator << (ostream& out, const a<T> & t)
{
out << t.t[0];
for (int i=1;i<256;i++)
out << ',' << t.t[i];
out << '\n';
return out;
}
int main(void)
{
a<int> b;
a<float> c;
a<float> d;
b.fill (99);
c.fill (88.888);
d=b;
b=c;
c.duplicate();
cout << b << c << d;
return 0;
}
- Raw text -