|
hey, so virtual destructor wont work if u the objects created at stack ? Bcoz in my example , A::destructor is called bcoz B is going out of scope. If my statement wrong can u pl give me sample with objects created in stack to test Virtual destructor.
thanks
|
|
|
|
|
Remember that B's destructor will call A's destructor...once it's finished any of your code in B's destructor. That is why A's destructor is being called.
Oh - and also, you won't see if B's destructor is called, because your print statement is in B's CONSTRUCTOR, not B's DESTRUCTOR!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
hi thanks,
(Ya i was put inside constructor by mistake - )
I understand that when B goes out of scope, A's destructor also called . But is there a way to see that virtual destructor is called for objects created at stack .
thanks
|
|
|
|
|
I really don't understand what you mean.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
I mean in my example,
int main()
{
B b;
A *ap = &b;
ap->getVal();//when B object goes out of scope, B's desc is called first then A's (here its not thru virtual destr)
//here i see virtual destructor is called ,(ie B'destc first then A's destr )
A *pb = new B;
delete pb;
}
So here i m trying to see B's destr called thru virtual destructor concept.
|
|
|
|
|
Virtual destructors are exactly the same as non-virtual destructors, except that a virtual destructor is included in the classes virtual function table (v-table).
All this means is that with a virtual destructor, a pointer to A will look for the correct destructor to call in the class's v-table. Without a virtual destructor, a pointer to A will not do this - it'll directly call A::~A.
With objects on the stack, this can never happen, because the compiler never deallocates the object through a pointer - it always destructs the actual object directly. This means that an object on the stack never has to look at its v-table to determine which destructor it should be calling.
What I'm basically saying is - the question you're trying to answer is meaningless.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
After using VC6++ for years I just purchased VS2008. It is radically different and I am quite confused. Is there a good tutorial or book that will teach me how to use MFC for this version. I don't want to use any of the managed code stuff or C#. I want to be able to do the things that were simple in VC6++.
For instance, put "This is a test in a ListBox". That was simple with VC6 and MFC. Four hours into VC++ 2008 and I haven't been able to get that to happen. In VC6 you could add a CString variable to a ListBox. There is no CString ListBox variable option for VC++ 2008.
Also, Class Wizard in VC6 allowed me to see any variable that had been assingned to a control. And Class View also allowed me to see all the variables that had been created for the project. Apparently neither one of the options are available in VC++ 2008. Class View doesn't show any control variables. In fact it doesn't show much of anything. And since I can't see the variables there appears to be no way to delete one once it is assigned to a control.
I do see the variables listed here:
CHIDTest2008Dlg::CHIDTest2008Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CHIDTest2008Dlg::IDD, pParent)
, m_strText(0)
, m_ListBox(0)
, strListBox(_T(""))
, m_strListBox2(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
But that is really of no use. And the online help is not much help. Am I missing something basic here or is this the way the environment really works. Was Microsoft trying to move everyone to managed code or C#?
Again, if anyone has a recommendation for a good book that only covers the MFC part of VS2008 I would appreciate them passing that along.
|
|
|
|
|
2buck56 wrote: In VC6 you could add a CString variable to a ListBox. There is no CString ListBox variable option for VC++ 2008.
a CString can cast itself to an LPCTSTR, so CListBox.AddString doesn't need an explict CString overload.
but, i can see class variables in the Class View. click on the class in the top pane, and the members will appear in the bottom pane.
|
|
|
|
|
Chris,
Thanks for the tip. I had been clicking on the + to expand the class. Clicking the class does display the variables as you said. Now, how would I delete one of the variables or functions? In VC6 you could do that with the Class Wizard. Do I have to manually remove the members in VC++ 2008?
|
|
|
|
|
2buck56 wrote: In VC6 you could do that with the Class Wizard. Do I have to manually remove the members in VC++ 2008?
don't know... i've always done it manually.
|
|
|
|
|
[Sarcasm] The removal of class wizard is one of the several intended "improvements". [/Sarcasm]
2buck56 wrote: In VC6 you could add a CString variable to a ListBox.
OK, this has nothing to do with visual studio versions, but I'd recommend using a control variable instead!
2buck56 wrote: Again, if anyone has a recommendation for a good book that only covers the MFC part of VS2008
Among other things, Beginning Visual C++ 2008[^] covers MFC as well.
I do hate some of the the "changes" that they've made. But at least the compiler has improved a lot.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
The loss of the class wizard drove me nuts at first. I still do a lot of work in VC6 and when the class wizard works, it's very refreshing. However, I'm reminded how often it fails and have found that I'm so accustomed to how VS 2008 works that a few things are now easier in VS 2008. Good news is that VS 2010 brings the class wizard back and improves on it, or at least parts of it (I haven't dug deeply into it.)
Do note that MFC itself hasn't changed much if up-porting an app. There is the feature pack additions (which range from interesting to totally junk) and there are some minor quirks when up-porting MFC.
As for the class wizard replacement; you use the properties. Triggering it is very confusing but you basically have to open the properties pane and .h file and click on the class name or the .cpp file and click in the message map block. A lightning, and two nonsense icons will pop up on the top of the pane which will show you events, messages and overrides.
Like I said, I totally hated this at first, but it's grown on me. I'll still welcome the class wizard back, but won't totally abandon this method. And given all the other niceties of VS 2008, I'm very ready to abandon VC 6 in about three week's time (I've actually already converted the entire solution to VS 2008, but we can't switch until we ship our current release, which is in beta. One very nice thing will be that our .NET and C++ modules will be built with the same solution for now on.)
|
|
|
|
|
Thanks everyone for the help and suggestions. I guess I'll just have to grit my teeth and learn the new IDE.
I manually deleted a couple of variables and classes from the test app that I was working on and it went well. Not as easy as the old class wizard but at least it works.
|
|
|
|
|
How can I get in MFC to display Operating system version(Vista, Xp, etc..) if possible? Any ApI, or Registry ?
|
|
|
|
|
It's all here[^] on MSDN.
MVP 2010 - are they mad?
|
|
|
|
|
Richard MacCutchan wrote: MVP 2010 - are they mad?
Definitely...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Definitely
Well at least we agree on one thing!
MVP 2010 - are they mad?
|
|
|
|
|
"You hate me and I hate you
So at least we understand each other"
--The Kinks
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I need a program in PHP which can extract the hidden biders from ebay.I will have to insert the item number and the program must show me all bidders of the auction and their emails.
Also the same program must extract the registered contact information for any specified bidder specially the email address
I will pay for this
If someone can help please contact me at totos_back@yahoo.com
Thanks
|
|
|
|
|
BTW: posting plain e-mail address on a public forum is silly.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Try rentacoder[^]
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
totolcm wrote: I need a program in PHP which can extract the hidden biders from ebay...and the program must show me all bidders of the auction and their emails.
Why? If eBay wanted you to have that info, they would not have got to such lengths to keep it from you.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
DavidCrow wrote: Why?
for feeding into a spam machine, of course.
why is it that half the questions on this forum come from people writing software that sounds like it's going to make all of our lives more miserable ?
|
|
|
|
|
This scumbag has posted his crap on pretty much every board. I hope the hamsters have their bugspray handy and deal with this infestation quickly.
|
|
|
|