Re: push_back problem.
From: Stephen Howe (sjhoweATdialDOTpipexDOTcom)
Date: 01/11/05
- Next message: sklett: "Re: find() w/ a user defined functor"
- Previous message: Stephen Howe: "Re: find() w/ a user defined functor"
- In reply to: Justin Marshall: "RE: push_back problem."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 Jan 2005 08:50:12 -0000
> Nevermind I got it working now, thanks : )
Well, have you really?
"Working" should not mean, "It runs through the debugger, no run-time error
therefore it must be okay".
It is possible for the program to be in error but it works out nothing is
triggered at run-time. You get lucky.
But add or subtract a variable and at that point you become aware that
something is wrong.
A minimal set of criteria for a working program, to me, is
(i) Where you make sure that the program does not do any "undefined
behaviour" (C++ standard terminology)
and the number of "implementation defined behaviour" points in your code is
minimal.
(ii) The number of casts is minimal
(iii) The compiler does not warn on anything at the highest level
(iv) There are no logical errors
(v) const correctness is respected
For example, you had
shaderParser->Cl_InitFile((char *)realfilename.c_str());
Is the cast because Cl_InitFile() takes a char * as parameter?
Could Cl_InitFile() be altered so it takes a const char * as parameter (it
is not being change within)?
If so I would make the change. You will then find you can do
shaderParser->Cl_InitFile(realfilename.c_str());
and if you used std::string within shaderParser and passed by const
reference, you could do
shaderParser->Cl_InitFile(realfilename);
But that is design.
Stephen Howe
- Next message: sklett: "Re: find() w/ a user defined functor"
- Previous message: Stephen Howe: "Re: find() w/ a user defined functor"
- In reply to: Justin Marshall: "RE: push_back problem."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|