|
I'm trying... I'll tell you the results tomorrow.
thanks
Russell
|
|
|
|
|
Hi,
I have found out (the hard way!) that you can't have a .cpp file with your function definitions if you are using a template class. All your function definitions must be in the .h file. Why is this?
Thanks for any info.
|
|
|
|
|
You can put the code in a C++ file, you just need to change how you define your templates.
I would not recommend that though, justuse a header file it's much easier.
regards,
|
|
|
|
|
Hi,
Thanks for that, but do you know why the C++ compilier objects to having function definitions in the .cpp ?
Thanks.
|
|
|
|
|
AFAIK it is because template code is generated by your compiler. It means that when you have a template instantiation (something like list<float> ) your compiler will generate code corresponding to this template type. To be able to generate the code, it needs the complete function implementation.
|
|
|
|
|
You do *not* have to have definitions in th ecpp.
You do this to (partially) separate interface and implementation.
With templates, every instantiation (for type A, type B etc) creates a new, distinct type: vector<A> is different from vector<B>.
And for this instantiation, the compiler needs the complete definition of the template. Therefore it is easiest to put the template in the header, to have it ready when you need it.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Yes, all in the .h file.
Only specializations must be putted in the .cpp file (declaraion, of course, in the .h file).
minkowski wrote: Why is this?
I think that this has only a reason related to how the compiler works to elaborates the templates.
I hope that this isn't a problem for you.
Russell
|
|
|
|
|
minkowski wrote: Why is this?
See here[^]
|
|
|
|
|
I have a list control of CListCtrl type and it has 3 columns. I want to hide the first column(of course, it will work internally). Is it possible?
|
|
|
|
|
Just out of curiosity, why do you need/want to do this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Cant you make it of zero width?
- NS -
|
|
|
|
|
How about setting the width of that column to zero?
MS
|
|
|
|
|
Can you more explain why you need to do it?
|
|
|
|
|
plz tel the Difference between debug and release builds.
|
|
|
|
|
the basic difference is the debug information will be embedded in the exe in debug build which is not possible in release build.is it suficient or are u looking for anything else.
|
|
|
|
|
Another difference is that debug mode can maybe work perfectly, but same code in release may crush in hundreds of places.
Debug assumes some things when nothing is said, or automatically correct some errors of intialization.
Release executes ONLY what the programmer has written. If it is not correctly written will crush.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Read this.
Also, there is an artice on the CodeProject I think but I can't remember its name.
|
|
|
|
|
|
Speed is the main difference a debug build will by default have no optimisation, this makes it easier to debug. But you can debug a release build it is just a little harder.
|
|
|
|
|
|
Hi
In my program i want to use
<br />
BOOL MapAndLoad(<br />
PSTR ImageName,<br />
PSTR DllPath,<br />
PLOADED_IMAGE LoadedImage,<br />
BOOL DotDll,<br />
BOOL ReadOnly<br />
);<br />
function in Imagehlp.h .
<br />
CPE::CPE(CString fileName, CString filePath):fileName(fileName),filePath(filePath)<br />
{ LOADED_IMAGE loi;<br />
::MapAndLoad((LPSTR)(LPCTSTR)fileName, (LPSTR)(LPCTSTR)filePath, &loi,FALSE, TRUE);<br />
int i = loi.NumberOfSections;<br />
char q[50];<br />
sprintf(q,"%d",i);<br />
MessageBox(NULL, q,NULL,0);<br />
}<br />
When i compiled and execute it. It gives error Messagebox with value -858993460 . I changed my projects setting use multibyte character set. wchar_t to char.
But can not find solution. What is wrong with this code?
How can i fix it?
Thanks.
|
|
|
|
|
sawerr wrote: What is wrong with this code?
You did not check the return value from MapAndLoad() , nor did you call GetLastError() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I checked the return value, it is not TRUE
MapAndLoad() is not working.
I changed code because of pstr parameters.
CPE::CPE(CString fileName, CString filePath):fileName(fileName),filePath(filePath)<br />
{ <br />
char *ch1 = strdup(fileName);<br />
char *ch2 = strdup(filePath);<br />
MessageBox(NULL, ch1, ch2, 0);<br />
<br />
PLOADED_IMAGE loi = ::ImageLoad((PSTR)ch1, (PSTR)ch2);<br />
<br />
<br />
<br />
BOOL b = ::MapAndLoad(ch1, ch2, loi,TRUE, TRUE);<br />
if(b == TRUE)<br />
{<br />
MessageBox(NULL, "DONE", NULL, 0);<br />
}<br />
<br />
ULONG i = loi->NumberOfSections;<br />
char q[50];<br />
sprintf(q,"%d",i);<br />
MessageBox(NULL, q,NULL,0);<br />
}
fileName and filePath parameters correct (they are coming from CFileDialog) but it gives run-time error in line ULONG i = loi->NumberOfSections;
Unhandled exception at 0x76c977f2 in PEInside.exe: 0xC0000005: Access violation writing location 0x00000004.
Do you have any suggestions?
|
|
|
|
|
If MapAndLoad() is returning 0 , why are you then proceeding to dereference loi ?
sawerr wrote: Do you have any suggestions?
Yes.
BOOL b = ::MapAndLoad(ch1, ch2, loi, TRUE, TRUE);
if (b)
{
CString q;
q.Format("%lu", loi->NumberOfSections);
AfxMessageBox(q);
}
else
{
CString q;
q.Format("%lu", GetLastError());
AfxMessageBox(q);
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for your help your last post really help me, i understood how i must write.
Thank you.
Good works...
|
|
|
|