dev-cpp-users Mailing List for Dev-C++ (Page 352)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Hossein H. <ult...@em...> - 2003-07-11 10:51:47
|
Dear Ioannis, > Btw I am not so sure what you have understood, but I have the sense that you > understood wrong things. Calling a member function using a pointer not > pointing to an object has undefined behaviour. Provided that lifetime of the pointing object is ended. Consider the following line of citation I had made from the Standard: > > pb->f(); //undefined behavior, lifetime of *pb has ended Let me know if I haven't still got the point you had meant. Regards, --Hossein -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup CareerBuilder.com has over 400,000 jobs. Be smarter about your job search http://corp.mail.com/careers |
|
From: Hossein H. <ult...@em...> - 2003-07-11 10:43:54
|
Dear Ioannis, > At the initial posting the poster were deleting an object upon its > construction. That meant that apparently she did not know what delete does > and perhaps what is a constructor. Is there a better advice than suggesting > her read a good C++ book? :-) Hmmm... You are right in the sense that she needs such a book, but that is not the whole story! For us as experienced C++ programmers (hope so!), it was a good topic, regardless of what had caused it. Wasn't it? I myself, had quite interesting struggle to find out what was going on! Wishes, --Hossein -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup CareerBuilder.com has over 400,000 jobs. Be smarter about your job search http://corp.mail.com/careers |
|
From: Daniel G. <sp...@ho...> - 2003-07-11 05:59:53
|
Thanks, that is VERY useful. VC++ is what we use at work you see, but I believe we're using to .NET soon. I'll look for the name of the book when I get to work (it's a 2000 book). >From: "Hossein Haeri" <ult...@em...> >To: "Daniel Glenfield" <sp...@ho...> >CC: dev...@li... >Subject: Re: [Dev-C++] Second STL example has a problem... >Date: Thu, 10 Jul 2003 13:56:56 -0500 > >Dear Daniel, > > > It's annoying because the examples don't show what headers to add nor >does > > it say about using namespace std (I'm going with Ioannis' theory about > > explicitly stating std:: in my code). > > > > This line is causing the problem in VC++ 6.0 > > > > std::vector<std::string> StrVector(Itr, EndOfFile); > > > > where Itr and EndOfFile are members of my class LineIterator > > > > I'm told by the compiler that Itr cannot be converted to an unsigned >int... > > thoughts? > >That's a known bug in VC++6. There are lots of them. Take a look at: > >http://www.acceleratedcpp.com/details/msbugs.html > >That's because there is no range constructor implemented in VC++6. > >I have to mention a recommendation that I had posted before: > >Don't count on VC++6. This nasty C++ implementation is not >Standard-compliant. Change your implementation as soon as possible. If >you need developery tools, consider BCB6 that is much more >Standard-compliant. Nothing in VC++6 is reliable! > >BTW, VC++7.1 is so far reported to be Standard-compliant, but it takes >time to test it really as it should. > >Regards, >--Hossein > >-- >__________________________________________________________ >Sign-up for your own FREE Personalized E-mail at Mail.com >http://www.mail.com/?sr=signup > >CareerBuilder.com has over 400,000 jobs. Be smarter about your job search >http://corp.mail.com/careers > _________________________________________________________________ Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile |
|
From: Ioannis V. <iv...@em...> - 2003-07-11 03:47:22
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Per Westermark > Sent: Friday, July 11, 2003 5:15 AM > To: dawood > Cc: Dev C++ > Subject: Re: [Dev-C++] three queries > > > Ioannis: My assumption about a question of a non-const > reference is not if > the reference may be changed, but if the object pointed to by the > reference may be modified. That is my assumption too. The other assumption you are mentioning, is someone else's assumption. :-) Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Per W. <pw...@ia...> - 2003-07-11 02:13:04
|
Is this a school assignment? If not, I would be more interested in what you want to solve. A lot of the time there are a number of questions how to write this and that complicated construct, when the original problem might have a simpler solution. What triggers my question is that a reference to a pointer to a pointer to char is a tripple indirection, since a reference is just a modified form of a pointer. Do you really, really need such a long way just to get in contact with a poor little character :-) Ioannis: My assumption about a question of a non-const reference is not if the reference may be changed, but if the object pointed to by the reference may be modified. /Per W On Fri, 11 Jul 2003, dawood wrote: > 1.does anybody know how to create a typedef for an array of 8 arrays of 7 > pointers to int. > > 2. char c[]="hello"; > char* pc= c; > char** ppc = &pc; > does anybody know a much shorter method to create a pointer to > pointer to char. I am doing it in 3 statements. Can anybody show me how to > do it in less than 3 statements. > 3. Also can anybody show me how to create a non constant reference to > pointer to pointer to char. > |
|
From: staale <st...@le...> - 2003-07-10 22:30:20
|
Hi Todd, When you have found a sample with google, as Per suggested, you should put this in mind: Some of the samples you find does not work if you do anything with the files (in the directory). Like create, delete and such after you have created appropriate filehandless. If you encounter problems make the system flush the file cache. I do not remember how It was done (google or alltheweb will be your friend..:o), but I spent several days on something like this some years ago. Just my 2c, on this one..:) Best regards Staale At 15:45 09.07.2003 -0500, Tod...@De... wrote: >Hello, > >I am new to C++. I like to read files name in the folder . For an example, >My path is "C:\temp\data ", and in the folder there are some files that i >need to read only file name like file1.dat , file2.dat , file3.dat .... all >my dat file. If anyone have any advice or good idea how to write this >function for me I will be very happy. Thank you very much > > >Todd c. > > > > > >------------------------------------------------------- >This SF.Net email sponsored by: Parasoft >Error proof Web apps, automate testing & more. >Download & eval WebKing and get a free book. >www.parasoft.com/bulletproofapps >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Aaron S. <as...@co...> - 2003-07-10 21:58:03
|
Hi I am rather new to dev-c++. I am using version 4.9.8.1. I have been trying to compile quake2 v3.2.1 full source from id software. I was lazy and used the import visual studio project option. Does anyone have a link to a site that i could visit to setup dev-c++ to compile the quake2 source properly. Also I noticed when I loaded the quake2 sources the class browser went a little funny. A blur of names went from top to bottom outside of the class browser. Under linux I have been able to get the quake2 source to compile fine. These are my first cracks at windows. Aaron as...@co... |
|
From: Adam M. <up...@in...> - 2003-07-10 21:56:24
|
> Hello, > > I am new to C++. I like to read files name in the folder . For an example, > My path is "C:\temp\data ", and in the folder there are some files that i > need to read only file name like file1.dat , file2.dat , file3.dat .... all > my dat file. If anyone have any advice or good idea how to write this > function for me I will be very happy. Thank you very much > Try FindFirst and FindNext or FindFirstFile and FindNextFile. You can specify diiferent parameters and file extension is one of them. FindFirst and aFindNext belongs to VCL library. FindFirstFile and FindNextFile are Win32 API functions. Remember to use FindClose. |
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:55:33
|
-----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of dawood Sent: Thursday, July 10, 2003 11:36 PM To: Dev C++ Subject: [Dev-C++] three queries 1.does anybody know how to create a typedef for an array of 8 arrays of 7 pointers to int. My mistake i had not seen the '1', so i answer it here: A direct answer (if i got what you want correctly): typedef int *ar[8][7]; Also you can reach your goal gradually: typedef int *par[7]; typedef par ppar[8]; This is an array of 8 pars which means it is an array of 8 arrays of 7 int * each. Another example to help you understand how typedef makes our lives better: typedef char char_array[10]; typedef char_array m_char_array[2]; m_char_array a; What is a? :-) Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com <http://www.noicys.freeurl.com/> * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:45:59
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of dawood
Sent: Thursday, July 10, 2003 11:36 PM
To: Dev C++
Subject: [Dev-C++] three queries
1.does anybody know how to create a typedef for an array of 8 arrays of =
7
pointers to int.
2. char c[]=3D"hello";
char* pc=3D c;
char** ppc =3D &pc;
does anybody know a much shorter method to create a pointer to
pointer to char. I am doing it in 3 statements. Can anybody show me how =
to
do it in less than 3 statements. =20
=20
=20
At first you should mention language, i assume C.
=20
A typedef? I do not see any typedef above. Perhaps today i have had much
critical mood but do you know what you are doing above?
=20
You create a char array in the automatic storage and then you point to =
the
first element of it using a char pointer and you point to that char =
pointer
using a pointer to char pointer.
=20
=20
If you want to access the first element of the array using the char ** =
you
can do directly:
=20
char c[]=3D"hello";
=20
char **ppc=3Dc;
=20
=20
3. Also can anybody show me how to create a non constant reference to
pointer to pointer to char.=20
=20
Well, you are talking about C++. You can't do that. You can use =
references
to pointers only to templates.
=20
=20
Example:
=20
template <class T>
inline T &rfer(T &r) { return r; }
=20
=20
But the above is useless.
=20
=20
=20
=20
=20
Ioannis Vranos
* Programming pages: <http://www.noicys.freeurl.com/>
http://www.noicys.freeurl.com
* Alternative URL 1: <http://run.to/noicys> http://run.to/noicys
* Alternative URL 2: <http://www.noicys.cjb.net/> =
http://www.noicys.cjb.net
|
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:40:50
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Smurf, Papa > Sent: Thursday, July 10, 2003 10:41 PM > To: Daniel Glenfield; dev...@li... > Subject: RE: [Dev-C++] Second STL example has a problem... > > > It's annoying because the examples don't show what headers to > add nor does > it say about using namespace std (I'm going with Ioannis' theory about > explicitly stating std:: in my code). That's nice, the "Ioannis theory". Everything in the standard library (except the contents of the .h C subset header files) is defined in namespace std, so it is not a theory. :-) Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Graham D. <g.d...@nt...> - 2003-07-10 21:35:25
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <title></title> </head> <body> Sounds like homework....<br> <br> 3. There's no such thing as a non constant reference. All references are "constant" in that they are not reseatable.<br> <br> dawood wrote:<br> <blockquote type="cite" cite="mid...@ku..."><font face="Courier New, Courier">1.does anybody know how to create a typedef for an array of 8 arrays of 7 pointers to int.<br> <br> 2. char c[]="hello";<br> char* pc= c;<br> char** ppc = &pc;<br> <x-tab> </x-tab>does anybody know a much shorter method to create a pointer to pointer to char. I am doing it in 3 statements. Can anybody show me how to do it in less than 3 statements. <br> 3. Also can anybody show me how to create a non constant reference to pointer to pointer to char.<br> </font></blockquote> </body> </html> |
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:21:39
|
> -----Original Message----- > From: Ioannis Vranos [mailto:iv...@em...] > Sent: Friday, July 11, 2003 12:19 AM > To: Dev-C++ Mailing List (dev...@li...) > Subject: RE: [Dev-C++] Second STL example has a problem... > > > That's nice, the "Ioannis theory". Everything in the standard > library (except the contents of the .h C subset header files) > is defined in namespace std, so it is not a theory. :-) Or better, the theory is right. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:03:29
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Hossein Haeri
> Sent: Thursday, July 10, 2003 9:34 PM
> To: dev...@li...
> Subject: RE: [Dev-C++] Constructor and Destructor
>=20
>=20
> After all, I found the following lines in the Standard draft, which I
> cite directly: (Section 3.8, Case 5)
>=20
> "Before the lifetime of an object has started but after the storage
> which the object will occupy has been allocated or, after the
> lifetime of an object has ended and before the storage which the
> object occupied is reused or released, any pointer that referes to
> the storage location where the object will be or was located in may
> be used but only in limited ways. Such a pointer referes to allocated
> storage, and using the pointer as if the pointer were of type void*
> is well-defined. Such a pointer may be dereferenced but the resulting
> lvalue may only be used in limited ways, as described below. If the
> object will be or was of a class type with a nontrivial destructor,
> and the pointer is used as the operand of delete-expresion, the
> program has undefined behavior. If the object will be or was a
> non-POD class type, the program has undefined behavior if:
>=20
> 1) the pointer is used to access a non-static data member or call a
> non-static member function of the object, or
>=20
> 2) the pointer is implicitly converted to a pointer to a base class
> type, or
>=20
> 3) the pointer is used as the operand of a static_cast (except when
> the convesion is to void*, or to void* subsequently to char* or
> unsigned char*).
>=20
> 4) the pointer is used as the operand of a dynamic_cast.
>=20
> Example:
>=20
> struct B
> {
> virtual void f();
> void mutate();
> virtual ~B();
> };
>=20
> struct D1: B { void f();};
> struct D2: B { void f();};
>=20
> void B::mutate() {
> new (this) D2; //reuse storage - ends the lifetime of *this
> f(); //undefined behavoir
> ... =3D this; //OK. this points to valid memory
> }
>=20
> void g() {
> void* p =3D malloc(sizeof(D1) + sizeof(D2));
> B* pb =3D new (p) D1;
> pb->mutate();
> &pb; //OK: pb points to valid memory
> void* q =3D pb; //OK: pb points to valid memory
> pb->f(); //undefined behavior, lifetime of *pb has ended
> }"
>=20
> (Gush! The pdf of Standard I have doesn't support copy/pasting so I
> wrote the whole by periodically jumping from this window to that one
> and vice versa.)
>=20
> I hope this to be clear enough. As now, I myself, can understand
> everything about that troublesome programme (which was quite handsome
> as well)!
Btw I am not so sure what you have understood, but I have the sense that =
you
understood wrong things. Calling a member function using a pointer not
pointing to an object has undefined behaviour.
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|
|
From: dawood <da...@ku...> - 2003-07-10 21:03:16
|
1.does anybody know how to create a typedef for an array of 8 arrays of 7
pointers to int.
2. char c[]="hello";
char* pc= c;
char** ppc = &pc;
does anybody know a much shorter method to create a pointer to
pointer to char. I am doing it in 3 statements. Can anybody show me how to
do it in less than 3 statements.
3. Also can anybody show me how to create a non constant reference to
pointer to pointer to char.
|
|
From: Ioannis V. <iv...@em...> - 2003-07-10 20:41:37
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Hossein Haeri > Sent: Thursday, July 10, 2003 9:34 PM > To: dev...@li... > Subject: RE: [Dev-C++] Constructor and Destructor > >As now, I myself, can understand > everything about that troublesome programme (which was quite handsome > as well)! At the initial posting the poster were deleting an object upon its construction. That meant that apparently she did not know what delete does and perhaps what is a constructor. Is there a better advice than suggesting her read a good C++ book? :-) Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Ioannis V. <iv...@em...> - 2003-07-10 20:35:57
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Abhijit Shylanath > Sent: Thursday, July 10, 2003 8:29 PM > To: Per Westermark > Cc: dev...@li... > Subject: RE: [Dev-C++] Constructor and Destructor > > > > > When you don't assign a value to b it will be > uninitialized, and set to > > any value that might be in memory. When you then call a > non-virtual method > > of the object, the method will thus get a random 'this' pointer. > > But shouldn't a protected-mode program crash when you try to access a > pointer that doesn't point to legally allocated memory? The behaviour of such calls is undefined. It may crash, it may not. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Smurf, P. <smu...@xs...> - 2003-07-10 20:07:18
|
It's annoying because the examples don't show what headers to add nor does it say about using namespace std (I'm going with Ioannis' theory about explicitly stating std:: in my code). I'm sorry but what book are you using? I'm a beginner and think I should avoid your book. hint: read the Amazon reviews or goto this site: http://www.accu.org/bookreviews/public/ <its not bad at all> |
|
From: Hossein H. <ult...@em...> - 2003-07-10 19:10:28
|
Dear Daniel, > It's annoying because the examples don't show what headers to add nor does > it say about using namespace std (I'm going with Ioannis' theory about > explicitly stating std:: in my code). > > This line is causing the problem in VC++ 6.0 > > std::vector<std::string> StrVector(Itr, EndOfFile); > > where Itr and EndOfFile are members of my class LineIterator > > I'm told by the compiler that Itr cannot be converted to an unsigned int... > thoughts? That's a known bug in VC++6. There are lots of them. Take a look at: http://www.acceleratedcpp.com/details/msbugs.html That's because there is no range constructor implemented in VC++6. I have to mention a recommendation that I had posted before: Don't count on VC++6. This nasty C++ implementation is not Standard-compliant. Change your implementation as soon as possible. If you need developery tools, consider BCB6 that is much more Standard-compliant. Nothing in VC++6 is reliable! BTW, VC++7.1 is so far reported to be Standard-compliant, but it takes time to test it really as it should. Regards, --Hossein -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup CareerBuilder.com has over 400,000 jobs. Be smarter about your job search http://corp.mail.com/careers |
|
From: Per W. <pw...@ia...> - 2003-07-10 18:37:30
|
It depends on luck. An uninitialized pointer may point anywhere in memory. Since in this case the pointer was allocated on the stack in main(), there is a big possibility that it will get a non-random value from the initialization code. A protected-mode program may only kill the program if the pointer access is outside of the memory allowed to the program, to protect other programs. The compiler would have to insert extra code - not all compilers supports extra debugging instrumentation for run-time data checking - to keep track of uninitialized values and what a pointer may or may not be used for. A protected mode system is not built for sw debugging, i.e. to make sure that a program is bug-free. /Per W On Thu, 10 Jul 2003, Abhijit Shylanath wrote: > > > When you don't assign a value to b it will be uninitialized, and set to > > any value that might be in memory. When you then call a non-virtual method > > of the object, the method will thus get a random 'this' pointer. > > But shouldn't a protected-mode program crash when you try to access a > pointer that doesn't point to legally allocated memory? > > -- > Abhijit Shylanath > Homepage: http://mudeth.tripod.com/ > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > www.parasoft.com/bulletproofapps1 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Hossein H. <ult...@em...> - 2003-07-10 18:36:49
|
Dear all,
After all, I found the following lines in the Standard draft, which I
cite directly: (Section 3.8, Case 5)
"Before the lifetime of an object has started but after the storage
which the object will occupy has been allocated or, after the
lifetime of an object has ended and before the storage which the
object occupied is reused or released, any pointer that referes to
the storage location where the object will be or was located in may
be used but only in limited ways. Such a pointer referes to allocated
storage, and using the pointer as if the pointer were of type void*
is well-defined. Such a pointer may be dereferenced but the resulting
lvalue may only be used in limited ways, as described below. If the
object will be or was of a class type with a nontrivial destructor,
and the pointer is used as the operand of delete-expresion, the
program has undefined behavior. If the object will be or was a
non-POD class type, the program has undefined behavior if:
1) the pointer is used to access a non-static data member or call a
non-static member function of the object, or
2) the pointer is implicitly converted to a pointer to a base class
type, or
3) the pointer is used as the operand of a static_cast (except when
the convesion is to void*, or to void* subsequently to char* or
unsigned char*).
4) the pointer is used as the operand of a dynamic_cast.
Example:
struct B
{
virtual void f();
void mutate();
virtual ~B();
};
struct D1: B { void f();};
struct D2: B { void f();};
void B::mutate() {
new (this) D2; //reuse storage - ends the lifetime of *this
f(); //undefined behavoir
... = this; //OK. this points to valid memory
}
void g() {
void* p = malloc(sizeof(D1) + sizeof(D2));
B* pb = new (p) D1;
pb->mutate();
&pb; //OK: pb points to valid memory
void* q = pb; //OK: pb points to valid memory
pb->f(); //undefined behavior, lifetime of *pb has ended
}"
(Gush! The pdf of Standard I have doesn't support copy/pasting so I
wrote the whole by periodically jumping from this window to that one
and vice versa.)
I hope this to be clear enough. As now, I myself, can understand
everything about that troublesome programme (which was quite handsome
as well)!
Regards,
--Hossein
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers
|
|
From: Abhijit S. <mu...@gm...> - 2003-07-10 17:46:07
|
> When you don't assign a value to b it will be uninitialized, and set to > any value that might be in memory. When you then call a non-virtual method > of the object, the method will thus get a random 'this' pointer. But shouldn't a protected-mode program crash when you try to access a pointer that doesn't point to legally allocated memory? -- Abhijit Shylanath Homepage: http://mudeth.tripod.com/ |
|
From: Marcos C. <ca...@un...> - 2003-07-10 13:24:18
|
Hello List! I need a electronic copy of paper "Data Access Template" published in C++ Report 9(7):15-21, 1997. Does anyone can help me? Thanks, Marcos |
|
From: Hossein H. <ult...@em...> - 2003-07-10 12:46:49
|
Dear Lohit,
> class A{
>
> public:
> A(){
> delete this;
> }
> ~A(){
> cout<<"~A";
> }
>
> f(){
>
> cout<<"HELLO\n";
>
> }
>
> };
>
> int main()
> {
> A *a=new A();//works
This works because A() returns a copy of "*this" inside it. So, in
calling the constructor, when you delete the "*this" pointer, there
isn't any problem as there is no other need to the copy returned by
A(), and it is going to be deleted by the compiler at the same time.
> A b;//crashes why?? how is it any different from above.
But, here, there is a problem, as you are deleting an object that is
deemed to be alive still. This is an auto object, right? So it is to
be destructed by the compiler, and be alive till that destructor is
called. But you are destructing it using "delete this", beforehand.
>
> A *c;
>
> c->f();//works why when I have not allocated any memory for
> this.
This works as compilers (or at least optimiser compilers) have only
one copy of the member functions. In fact, they are shared between all
the instantiations of a class. As the only differences between
different objects of a class are the data members of them. So there is
only one copy of any member function for a given class. Therefore,
A::f() is created and when c->f() is called, in fact, A::f() is
called.
>
> }
Regards,
--Hossein
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers
|
|
From: Daniel G. <sp...@ho...> - 2003-07-10 12:44:36
|
It's annoying because the examples don't show what headers to add nor does
it say about using namespace std (I'm going with Ioannis' theory about
explicitly stating std:: in my code).
This line is causing the problem in VC++ 6.0
std::vector<std::string> StrVector(Itr, EndOfFile);
where Itr and EndOfFile are members of my class LineIterator
I'm told by the compiler that Itr cannot be converted to an unsigned int...
thoughts?
class definition:
#include <iostream>
#include <algorithm>
#include <string>
class LineIterator
{
public:
std::istream* In;
std::string Line;
bool IsValid;
/* Inlined function Read() is
used to check for a non-null
pointer and then gets user
input. If non-null input the
user has entered valid data.
*/
void Read()
{
if (In)
{
std::getline(*In, Line);
}
IsValid = (*In) ? true : false;
}
typedef std::input_iterator_tag IteratorCategory;
typedef std::string ValueType;
typedef ptrdiff_t DifferenceType;
typedef const std::string* StrPtr;
typedef const std::string& StrRef;
/// Constructor
LineIterator() : In(&std::cin), IsValid(false){}
/// Overloaded constructor.
LineIterator(std::istream& IStrmObj) : In(&IStrmObj) { Read(); }
/**
* @Group OperatorOverrides
* The operator overrides for the LineIterator class.
*/
// Operator override for the * operator.
StrRef operator*() const { return Line; }
// Override the indirection operator
StrPtr operator->() const { return &Line; }
// Override the increment operator
LineIterator operator++()
{
Read();
return *this;
}
LineIterator operator++(int)
{
LineIterator Temp = *this;
Read();
return Temp;
}
bool operator==(const LineIterator& LineItrObj) const
{
return (In == LineItrObj.In && IsValid == LineItrObj.IsValid) ||
(IsValid == false && LineItrObj.IsValid == false);
}
bool operator!=(const LineIterator& LineItrObj) const
{
return !(*this == LineItrObj);
}
// End of group.
};
_________________________________________________________________
Hotmail messages direct to your mobile phone http://www.msn.co.uk/msnmobile
|