|
>>> Well, first off you're not using pointers, you're using references. The virtual-ness of fn() is irrelevant because polymorphic calls only happen when dereferencing a pointer.
Not true. Polymorphism still works even if you're using references. For example:
<br />
D d ; <br />
B& x = d ; <br />
x.fn() ; <br />
prints "in D" i.e. even though we are using a B reference, the program knows that we really have a D object and calls the appropriate virtual function.
>>> Second, foo() returns a B&. Since a B& object cannot be implicitly converted to a D& object, the D& catch is not invoked.
As I said, I could understand if this was the case i.e. the compiler uses the *static* type of the exception to determine which catch handler to invoke. What I don't get is why, given that the actual object being thrown is a D, the virtual function mechanism doesn't seem to be working properly. Or at least, as I would expect
One of the guys at work here suggested that the object was being sliced, but since nothing is ever being *copied*, no slicing could possibly be taking place!
|
|
|
|
|
I wuz wrong! The exception *does* get copied.
From "More Effective C++", item 12:
Regardless of whether the exception is caught by value or by reference (it can't be caught by pointer — that would be a type mismatch), a copy of localWidget will be made, and it is the copy that is passed to the catch clause. This must be the case, because localWidget will go out of scope once control leaves passAndThrowWidget, and when localWidget goes out of scope, its destructor will be called. If localWidget itself were passed to a catch clause, the clause would receive a destructed Widget, an ex-Widget, a former Widget, the carcass of what once was but is no longer a Widget. That would not be useful, and that's why C++ specifies that an object thrown as an exception is always copied
So, since at the moment the object is being thrown, we have a B&, a B object is what we get. Sigh...
|
|
|
|
|
Michael Dunn wrote:
Well, first off you're not using pointers, you're using references. The virtual-ness of fn() is irrelevant because polymorphic calls only happen when dereferencing a pointer.
Yes? A reference is an auto-dereferencing pointer.
|
|
|
|
|
Is RasDial a blocking call? Meaning, does it only return after the connection has been established or if the connection has failed? I have got confusing results in my few experiments here And for non-coding reasons (mostly involving angry co-workers staring at me) I am unable to do further experiments
Any help would be hugely appreciated!
Thanks and regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
You can have RasDial work in a non-blocking fashion: just pass a suitable callback in the lpvNotifier parameter.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Hello, the codegurus around the world.;)
Check the message called WM_RASDIALEVENT by RasDial,
and compare wParam with RASCS_XXXX.
So, we can check the process of dialing.
Good Luck
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Nish,
Dundas offers a free RASDIAL class, which worked like a miracle for me!
Register first
http://www.dundas.com/products/downloads/register.asp?ProdID=4
VictorV
|
|
|
|
|
|
Hi all, I downloaded a program source code from internet and failed to compile it, the reason is a header file named "iphlpapi.h" could not be found on my computer.
Could someone tell me why I don't have it? I'm using VC++6.0 on Win2000pro(sp3). Thanks in advance.
|
|
|
|
|
|
I guess it only comes with VC7? I really need to compile that program but don't wanna install VC7. hmm...
|
|
|
|
|
|
Hello, the codegurus around the world.;)
After we install Microsoft Platform SDK, we must point the new
include and lib directory in Visual Studio.
Tools -> Options -> Directories Tab -> Include files and Library files
item in ComboBox -> Add the new directory.
(Sometimes, we had better change the order of these indice at some project.)
Have a fun.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Hey thanks everyone who replied.
|
|
|
|
|
My service is based on MFC Dialog. I can show a system tray icon when I login. But I find a strange problem. When I logoff then re-login. The service works great. But if I logoff again, win2000 will not logoff? The problem comes from my interactive service. Because if I close it, win2000 works normaly.
Any NT service expert help me ?
|
|
|
|
|
Is it possible that your service refuse to shut down?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Hello,
I am new to ths so please be kind.
I am using C++ and I want to Parse a XML message and change some data and then submit it to the next process. I think a DOM parser is what I need.
I am using VC++ .NET.
Can someone please give a snipt of code of how to do this? What I am doing must be wrong becuase I do not get any attributes or elements from the message.
Here is what I was trying to do.
memset(ls_message, 0x00, sizeof( ls_message ) );
BuildMessage(ls_messagestruct, ls_message);
XmlDocument* mydoc = new XmlDocument();
strcpy(buffer, ls_message );
mydoc->LoadXml(buffer);
XmlNode* root = mydoc->DocumentElement;
XmlNodeList* xnl = mydoc->ChildNodes;
XmlAttributeCollection* attributes = mydoc->DocumentElement->Attributes;
IEnumerator* ie2 = attributes->GetEnumerator();
IEnumerator* ie = xnl->GetEnumerator();
while ( ie2->MoveNext() == true )
{
Console::WriteLine("Attribute:{0} Value {1}", (dynamic_cast<xmlattribute*>(ie2->Current))->Name,(dynamic_cast<xmlattribute*>(ie2->Current))->Value );
}
while ( ie->MoveNext() == true )
Console::WriteLine("Child: {0}", (dynamic_cast<xmlnode*>(ie->Current))->Name);
while ( ie->MoveNext() == true )
{
XmlNode* pNode = dynamic_cast<xmlnode*>(ie->Current);
if( pNode->NodeType == XmlNodeType::Element )
{
Console::WriteLine(" Found The root ");
//processRoot(pNode);
XmlTextWriter* xtw = new XmlTextWriter(Console::Out);
xtw->Formatting = Formatting::Indented;
mydoc->WriteTo(xtw);
xtw->Flush();
Console::WriteLine();
}
else
{
Console::WriteLine(" Root Was not Found ");
}
}
Thanks for the help
|
|
|
|
|
Isn't there a function that you can call to set the color of a particular control?
I'm guessing not, so is there an easy way I can set the color for an edit box back ground? If I have to owner draw this does anyone have a class that I can subclass this to?
Thanks again!
|
|
|
|
|
|
will we get to see the source code?
|
|
|
|
|
|
I took a look at the HTTP example on codeproject that explains the GET and POST command:
http://www.codeproject.com/internet/HTTPGet-Post.asp
Now, i thought i understood perfectly well what was going on, when you type in a url in your browser it connects via tcp to that server and sends a header to that server to retrieve a page.
Now there's this site http://www.proximus-interactive.be of our mobile operator, just a commercial site like any other. But spooky enough, i wrote an application that tries to connect to port 80 on www.proximus-interactive.be and it wont connect!! but when i surf there in my browser it works fine... doesn't that mean my browser connects to it..on port 80? cause its the default.. and i noticed other sites do the same thing, and its really bugging me. If anyone knows whats causing this please explain.
Thank you very much in advance.
P.S.: i can connect to a bunch of other sites just fine, so its not me :p
Kuniva
--------------------------------------------
|
|
|
|
|
See if you can connect using Chris' WebGrab[^] sample. It's possible that the server may be refusing your connection based on the agent name.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi, The webgrab sample you directed me to used the CInternetSession class to do all the connection things itself, there is no code in the Webgrab sample that actually shows the connection being made, it just uses functions from CInternetSession. And the Agent cannot be the problem because i simply cant connect to the server, i cant even send the agent!
But now i was thinking, i use a proxy server, maybe it has something to with that? maybe do i just need to connect to my proxy and post the request there??? or how does that work??
Thank you for your reply and help.
Kuniva
--------------------------------------------
|
|
|
|