|
«_Superman_» wrote: try
{ BYTE*pp=new BYTE[iSize];}catch (exception& e){ cout << e.what();}
It one the correct way to resolve problem, but still there are some exception which can't be handlled by exception block too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Seeing as the man said the pointer was sometimes 0 when it came back from new he's using an antique compiler which doesn't follow the standard (e.g. VC++6). Catching anything isn't going to help here.
Cheers,
Ash
|
|
|
|
|
It could be a symptom of another memory problem elsewhere. Enable memory testing and rerun your program.
It could also be (as someone else suggested) a memory leak being repeatedly executed. If so, this one is easy to fix: make the bb variable static and initially NULL. Then if it's not NULL, free it before assigning the new buffer to it.
|
|
|
|
|
In visual Studio, there is a shortcut for going to the function definition. Let me give an example
VOID ABC::abc() {
int result;
result = someFUNC();
}
Now if we press some shortcut key on someFUNC, it takes us to that function. What is that shorcut?? thanx
|
|
|
|
|
Place your mouse over the function and press Right-Click, the pop-up menu will show you the option. In VC++ Express Edition it is F12.
It's time for a new signature.
|
|
|
|
|
F12 will work not only on Express editions
|
|
|
|
|
By my knowledge, in order to make a class recognizable in another module of an application, I need to include it's header file or, at least, to use a forward declaration.
I'll ask my question using an example. Let's suppose I have an application named Test. In the CTestView class I have the function GetDocument() returning a pointer of CTestDoc* type. How doess the view class know about the CTestDoc* type if there is no "#include TestDoc.h" declaration in the CViewTest class ?
|
|
|
|
|
As you have mentioned, to use CTestDoc*, you will have to include TestDoc.h. If the CTestDoc* referenced only in the .CPP file, then check if the .CPP has included TestDoc.h
|
|
|
|
|
The obvious thing to do is look at what headers are included in CTestView.cpp and see if one of those contains a #include CTestDoc.h .
It's time for a new signature.
|
|
|
|
|
Somewhere there's a declaration for CTestDoc. Quite where it is might be another matter. You might find it's somewhere obscure i.e. in CTestView you include the document header before the view header but it'll be there.
Cheers,
Ash
|
|
|
|
|
I'm assuming you're asking how CTestDoc is referenced in the CTestView class in the TestView.h file.
If you look in the TestView.cpp file you will see the following 2 lines -
#include "TestDoc.h"
#include "TestView.h"
Here you will notice that TestDoc.h is included before TestView.h .
This way the CTestView class already knows about the CTestDoc class.
Change this to the following and you can expect errors at exactly the place where you're talking about -
#include "TestView.h"
#include "TestDoc.h"
|
|
|
|
|
Thanks for the help, I learned something from everybody who answered.
_Superman_'s answer was the shoot right in the bull's eye.
|
|
|
|
|
CString(0xcccccccc) wrote: How doess the view class know about the CTestDoc* type if there is no "#include TestDoc.h" declaration in the CViewTest class ?
Probably the include is done by one of the standard MFC include (afx.h or something similar)
In general, the document does not know the view(s); the view know about the document (GetDocument)
When the document (CDocument derived class that contains the data(*)) is modified then there should be a message is sent to update the views or in the case of the CDocument a method is called (CDocument::UpdateAllViews) that will eventually call (by message?, don't recall the exact mechanism) CView::OnDraw which should be overriden in your CView derived class so that the view is refresh after a change in the CDocument..
Watched code never compiles.
|
|
|
|
|
hello guys....well sometimes it happens that when I modify my code, despite savinf the changes in the code, following error occurs
fatal error LNK1000: Internal error during IncrBuildImage
wat can be the reason??
|
|
|
|
|
Microsoft has a patch for this. Search their site for this error message.
|
|
|
|
|
Friends,
I am very new to this community, i want to create a DLL and use the DLL Further in Other Applications can u please tel me the process to create the same or any sample refernce so that i can be done with myapplications. thanks
|
|
|
|
|
Hi,
a lot of questions get answered right away by Google, so try this[^].
|
|
|
|
|
hello guys.....i wanna ask can we use old traditional fopen and fwrite for reading and writing files in dialog-based vc++.net app, if so, an example will be appriciated?? thanx for value-able answer.
modified on Saturday, July 24, 2010 3:02 AM
|
|
|
|
|
You could probably give it a quick test by referring to this page[^].
It's time for a new signature.
|
|
|
|
|
thanx alot....I had just done it but using CFile class and could not find the exact way.
|
|
|
|
|
You're welcome. Don't forget when using managed code (VC++.Net) that you cannot also use MFC classes. However there are also many useful file handlers in the System.IO namespace[^].
[edit]I see the prat one-voter has been creeping around ... I don't mind being down voted for my suggestion, but at least have the courage to tell me why I'm wrong.[/edit]
It's time for a new signature.
modified on Sunday, July 25, 2010 3:29 AM
|
|
|
|
|
Richard MacCutchan wrote: edit]I see the prat one-voter has been creeping around ... I don't mind being down voted for my suggestion, but at least have the courage to tell me why I'm wrong.[/edit]
Who so ever he/she was, let me square it! 5 points for your post!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You, sir, are a true gentleman, thank you.
It's time for a new signature.
|
|
|
|
|
Hi!
When I run my application, it crashes at this line curTab->getElementFromId(i)->remove(); and displays:
Unhandled exception at 0x00632175 in SlogOut3D.exe: 0xC0000005: Access violation reading location 0x00000000. When I view the Memory contents at this location 0x00632175, it has:
8b 11 8b f4 8b 8d 18 ff ff ff 8b 42 18 ff d0 3b f4 e8 3e 64 ee ff eb b1 5f 5e 5b 81 c4 e8 00 00 00 3b ec e8 2c 64 ee ff 8b ...ô...ÿÿÿ.B.ÿÐ;ôè>dîÿë±_^[.Äè...;ìè,dîÿ.
curTab is a pointer.
What is wrong with this program? How to run with out crash?
|
|
|
|
|
"0xC0000005: Access violation reading location 0x00000000" means you are using a NULL pointer.
So either curTab is NULL or getElementFromId(i) returns NULL. You can fix the crash by checking the curTab-pointer and the pointer returned by getElementFromId(i) before using it.
|
|
|
|