|
Thanks for that link, (P?) Diddy.
I've already put it in my Fav. list.
I Dream of Absolute Zero
|
|
|
|
|
No problem,
I teach C++/MFC/COM during evenings (while doing it for a profession during the day - mad - yes thats me) and regulary hand a print out of that site as is to explain the difference between scalar and vector delete - it expalins it pretty well i think.
|
|
|
|
|
Using delete without [] causes memory leaks when you're dealing with an array because actually you only get the first element destructed and released memory for, I think. You won't get much optimization by doing so anyway, so why risk?
|
|
|
|
|
Johann Gerell wrote:
char* p = new char[10];
.
.
.
delete p;
What if you changed char to CString ? Then you'd have to remember to also change the delete statement.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
DavidCrow wrote:
What if you changed char to CString?
I wouldn't.
Off the top of my head... hmmm... I don't think I've ever created a CString on the heap.
But I get your point.
--
Dad, how strange it is that the pig can speak. *thoughtful pause* It must have lost its "oink". (my 3-year old daughter Moa, while watching Babe)
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
|
WRONG WRONG WRONG WRONG WRONG...
Just because it sometimes works ok doesn't mean it is a good thing to do. The standard specifically states that you must pair new with delete and new [] with delete []. On some implementations it might work ok, but on others it might totally fail. Also, if someone overrides new[]/delete[] for your object in question, you would be invoking the wrong delete method.
VERY VERY VERY BAD IDEA!!!!!!
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I skip [], since there's no destructor for char
You're wrong on this count. All types - internal plus user defined, all have constructors and destructors.
For example, ever tried:
int y(10);
which is the same as:
int y = 10;
The () indicates that it is a call to int's constructor.
each type also has predefined assigment(=), +, - etc. operators.
Bikram Singh
|
|
|
|
|
Nooooo.
int y = 10:
mov dword ptr [ebp-4],10
int y(10):
mov dword ptr [ebp-4],10
Simple - move "10" onto the stack. In contast to a C'tor call which would look something like this for class CBase:
lea ecx, [ebp-4]
call @ILT + X(CBase::CBase)
Note the call )
There is no difference between y(10) and y = 10 - they are primitive types - built into the language and supported by CPU registers - this is not Java!
|
|
|
|
|
i am using OLE IPicture interface to load images but i am having troublr with the foolowing line of code
"OleLoadPicturePath(OlePathName,NULL,0,0,&IID_IPicture,(void *)(&Ipic));"
when i try to compile it the compile genertes a type casting error for parameter 5.
i think i am using the correct syntax. Can any one tell me what the problem is.
Aizaz
|
|
|
|
|
Aizaz wrote:
OleLoadPicturePath(OlePathName,NULL,0,0,&IID_IPicture,(void *)(&Ipic));
You only fed it 6 arguments for that function. No wonder~~~
Maxwell Chen
|
|
|
|
|
Its defined as :
STDAPI OleLoadPicturePath{
LPOLESTR szURLorPath,
LPUNKNOWN punkCaller,
DWORD dwReserved,
OLE_COLOR clrReserved,
REFIID riid,
LPVOID *ppvRet
}
So parm 5 is of type REFIDD - in C that expands to IID* or in C++ it expands to IID&. Your passing &IID_IPicture - IE IID*. Change it to:
OleLoadPicturePath(OlePathName,NULL,0,0,IID_IPicture,(void *)(&Ipic));
On a side note, 6 is also wrong. Its of type LPVOID* - or void**. So persuming your IPic is IUnknown* (or whatever) you pass (void**)&Ipic - so in total
OleLoadPicturePath(OlePathName, NULL, 0, 0, IID_IPicture,(void**)&Ipic);
|
|
|
|
|
It should be IID_IPicture and not &IID_IPicture
|
|
|
|
|
Hi!
I'm reading from a bitmap file using CFile.. without specifying if its binary or text mode..
Now I tried sending the bytes read from the bitmap file to a network...
Now the maching on the other side gets the bytes, and then displays the bitmap to its own screen..
the machine on the other side of the network gets the bytes completely, no data loss..
but he can't draw the bitmap from the bytes it received...
DO i have to specify the file that opened to be binary? or does it have something to do with the byte-ordering of two different machines?
|
|
|
|
|
Maverick wrote:
I'm reading from a bitmap file using CFile.. without specifying if its binary or text mode..
According to the Open() method, CFile objects are always binary.
Maverick wrote:
or does it have something to do with the byte-ordering of two different machines?
On the receiving machine, save all of the bytes received to a file. Then try and open the file with some imaging software. If the graphic is rendered correctly, you'll know that the bytes were received correctly.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Anybody have sources in Visual C++ to program a Bluetooth device? It's something to do with the Ericsson Application Tool Kit. Please help.
Thank you.
|
|
|
|
|
You have an Ericsson Tool Kit under Windows...??? arf, i've been looking for such for the 2 last months, so i decided instead for using Metrowerks CodeWarrior for the code i use inside the telephone, and the server is under linux for me.
Bluetooth is a quite deep part of the Nokia /SonyEricsson mobiles...
TOXCCT >>> GEII power
|
|
|
|
|
Hi,
Is there anyway to convert a .RTF document automatically to .PDF? When for example Acrobat Distiller is installed, there is a button to convert a Word document to PDF file. I want the same action but automatically without user doing anything.
Any thoughts about this?
Best regards,
Jens
|
|
|
|
|
Hi,
It might help if you can give more details. There
are "PDF toolkits" available to help create PDF files
programmatically but then you will need to "parse" the
RTF yourself.
Another way is "printing" to something like Adobe's
PDFWriter.
Regards
Mahendra
|
|
|
|
|
Hi
My collegue has programmed a library to export to .RTF files ... I can use this but some clients ask it to be .PDF .... I have installed Acrobat Distiller to print to PDF .. so printing to PDF itself is no problem .. Words supports that easily too ... The problem is ... This needs to be done from code itself.
If they click on button 'PDF' .. then the document is first build in .RTF and after that .. needs to be "printed" to .PDF file.
Greetings,
Jens
|
|
|
|
|
Print to Acrobat Distiller just like you would any other printer. The Acrobat Distiller driver will either prompt you for the target file, or it can be supplied programmatically.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
Yours is a "custom" application which needs to "create/ save as"
PDF documents? If that is true than you would need something similar
to what you have for RTF; there are commercial libraries available to
write PDF files as well.
Due Regards
Mahendra
|
|
|
|
|
Hi!!
Adding WS_THICKFRAME to dialog style adds the system icon to de dialog.
I just want to remove it (not to change) but the only way I found using dialog editor is removing WS_SYSMENU that aditionally removes close small icon too.
Any way to just get rid off the icon?
SetIcon(NULL,FALSE) doesn't work;
Thanks in advanced.
Carlos
|
|
|
|
|
Just commenting these 2 lines in OnInitDialog
works for me in both vc 6.0 & vc 7.x
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
|
Hello everyone,
I'm very sorry if this has been posted already, but my searches for a SOLUTION to this problem have been fruitless thus far.
If there is ANY type of error in either my embedded Visual C++ or my VC++ 6.0, the build hangs. I can still save and modifiy files, but my build menu is completely blacked out except for "stop build" which does not work.
Has anyone encountered this before?
Thanks in advance,
s.
|
|
|
|