|
Tried removing the *. Didn't work either. Asserted on the Create call only.
|
|
|
|
|
AmorphousP wrote:
CDns* DnsCl = new CDns;
This is the part where I am creating the object on the heap in a function of another class, CDnsThread. This is the code that asserts.
What line of what file is firing the assertion? Have you set a breakpoint in the constructor of CDns and stepped through it?
AmorphousP wrote:
CDns* DnsCl;
This is the part when it is created on the stack. It doesn't assert but now when I call a public member fuction of the CDns class like
DnsCl->GetSMTPAddress(domain);
...
causes an 'access violation'.
I'm not surprised. How is this working without the new operator being called?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Actually the object is getting created dynamically now and I tried stepping through the constructor of CDns.
DnsSocket = new CSocket;<br />
SockStatus = TRUE;<br />
if (DnsSocket)<br />
{<br />
if (!DnsSocket->Create(0, SOCK_DGRAM, 0))
It's asserting on Create. It's here that it gives an access violation. The ASSERT that fires it is
ASSERT(CAsyncSocket::LookupHandle(hSocket, bDead) == NULL);
in the file sockcore.cpp
DavidCrow wrote:
AmorphousP wrote:
CDns* DnsCl;
This is the part when it is created on the stack. It doesn't assert but now when I call a public member fuction of the CDns class like
DnsCl->GetSMTPAddress(domain);
...
causes an 'access violation'.
I'm not surprised. How is this working without the new operator being called?
It was actually a desperate attempt to get the work done although wasn't a very logical choice.
|
|
|
|
|
AmorphousP wrote:
DnsSocket = new CSocket;
What do u do before this line ? You must be calling Create() before the socket object is initialized.
Dharani Babu S
|
|
|
|
|
I actually solved the problem. The trouble was that this code (DnsSocket = new CSocket ) is written inside a new secondary thread. As such there was no initialization code for winsock in the thread and that's why the code was asserting on DnsSocket->Create() . Now it works fine
-----------------------------
Nobody got anywhere in this world by simply being content.
|
|
|
|
|
Hi!
I recently stumbled over this interesting phenomenon using abstract member functions:
The situation is this: We have an abstract base class that defines an interface. In the constructor of the base, a specific implementation dependent task needs to be carried out, so an abstract
member function is invoked in the constructor. The behaviour of this member function is defined by derived classes.
If no function body is provided for this abstract function in the base class, a linker error occurs (unresolved symbol). If we provide an empty body, in the base, everything links fine and the vtable
lookup correctly resolves the implementation of the deriving class.
The question is this: If the abstract function is resolved at run-time anyway, through use of vtables, why give me a compile-time error if I don't provide a body that will, due to it being an abstract
function, never be used in the first place?!
Is this a Microsoft specific behaviour bug/"feature", or is this standard ISO behaviour?
I compiled this using MS VS .NET 2003
Thanks for any thoughts about this.
Nick
Here is some exaple code for you to check it out:
<br />
#include <stdio.h><br />
class base<br />
{<br />
public:<br />
base()<br />
{<br />
abstractFunction();<br />
}<br />
virtual ~base() {};<br />
<br />
<br />
virtual void abstractFunction() = 0 ;<br />
};<br />
<br />
class derived : public base<br />
{<br />
public:<br />
derived() {};<br />
virtual ~derived() {};<br />
<br />
void abstractFunction()<br />
{<br />
printf("works\n");<br />
}<br />
} testInstance;
This code should print "works" to the console, since the
As soon as you uncomment the function body of base::abstractFunction(), everything will link fine and work as expected.
|
|
|
|
|
You cannot call a virtual function of a derived class from a base class constructor. This is due to the order of construction. Base classes are built first so there is no vtable pointer available to call the correct function in the derived class, which is yet to be constructed.
You need the function body as the virtual call compiles to the base class member function not the derived class one.
You need a two stage construction method to handle what you need to do.
x = new drieved;
x.Initialise();
Where the initialise function calls the correct virtual functions once the object is fully constructed.
If you vote me down, my score will only get lower
|
|
|
|
|
Ah, I see.
That escaped my attention. Quite obvious though, come to think of it. (->silly me)
So the fact that my example code works OK is only by chance and not a regular case and more complicated classes or a release version compile might produce unpredictable results.
Thanks for the comment.
Nick
|
|
|
|
|
|
Hi,
Is it possible to "peek" stdin (i.e. check if any data is available) for a Win32 "kind of" console application?
Problem: A thread has to read stdin, but needs to react on an event
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
See if GetStdHandle() , and ReadConsoleInput() or ReadFile() are of any help.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi, I just made a program and I put a button in the dialog and called it IDAbout I need to get it so that when this button is clicked it open up another Dialog that I have made called IDD_ABOUTBOX. Can any body please help me write a code for the button so that it opens up the about box?
I am using MFC Dialog based project.
Thanks in advance.
|
|
|
|
|
Have you created a class for the IDD_ABOUTBOX dialog?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Ok, have you used ClassWizard to create a handler function for the clicking of the button?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes I have. Ijust dont know the script to put into:
void CMizfarsProgramstringtestingDlg::OnAbout()
{
// I need the code to put here to get it to open IDD_ABOUTBOX
}
To link it to the About Box.
Thanks
|
|
|
|
|
Construct an instance of the second dialog and call its DoModal() method.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
can you dum it down a bit please. I am only starting out with programming so i dont know much. Please can you explain it as if you were explaining to layman.
|
|
|
|
|
Buyer1 wrote:
can you dum it down a bit please.
I much prefer the phrase "less experienced."
Not knowing what name you gave your dialog class, I can only give you an approximation.
void CMizfarsProgramstringtestingDlg::OnAbout()
{
CMyOtherDlg dlg;
dlg.DoModal();
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
First i am sorry about that phrase.
Secondly:
I tried what you told me, but i keep getting this error when i compile:
midl : command line error MIDL1001 : cannot open input file Program.
I dont know what it means.
I put this code in:
CAboutDlg dlg;
dlg.DoModal();
|
|
|
|
|
Buyer1 wrote:
Secondly:
I tried what you told me, but i keep getting this error when i compile:
midl : command line error MIDL1001 : cannot open input file Program.
Are you doing something with COM? Using AppWizard, what type of application did you opt for, and what other options did you select?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Wait that was something else.
Sorry about that.
I got it working how you told me.
Thank you so very much!!!
|
|
|
|
|
Hi Community,
I want to extend the detail view of the explorer shell to handle video summary information for mp4 files in the summary tab of the advanced property page under XP on an NTFS file system.
This behavior is already included for mp3 and avi files, although mp3 and avi aren't compounded documents. So therefor, I must implement the IPropertySetStorage interface. What do I have to do to implement that interface? Is there an example somewhere?
It is important to me, that the metadata is not stored in an additional NTFS
stream, but inside the mp4 file itself. So I have to handle this by my
own shell extension code. But how, where, when ...
Thanks in advanced,
David
|
|
|
|
|
I have added a define in my Visual Studio .Net configuration. However my #ifdef's do not see the define. Anyone knows how this can be?
|
|
|
|
|
Hi,
I have a CDateTimeCtrl which I am growing in size when the focus is set and shrinking back to its normal size when focus is killed.
at the moment the only way I can get the control to lose focus is to set the focus onto another control.
Ideally when the user clicks anywhere outside of the control the focus should be lost and the CDateTimeCtrl shrink back to its normal size, but I can't see how to capture a mouse click on a CDateTimeCtrl.
The ComboBox control obvioulsy does something similar but can I do it with my CDateTimeCtrl?
Many Thanks
|
|
|
|