|
You will need to create a virtual destructor if you plan on using your classes polymorphically. However it is good practice to make sure that you always define base classes with virtual destructors to leave that option open for you in the future.
If you create a Derived object B, and store it in a base class pointer A, when you call delete on A for a non-virtual destructor, the destructor for A will be called. However if you declare the destructor virtual, then B's destructor will be called first, and B's destructor automatically calls A's destructor. This memory leak is called slicing.
Here is a small sample program that shows what happens when you have a polymorphically stored derived class in a base class pointer where the base class does not have a virtual destructor.
#include <conio.h>
#include <iostream>
using std::cout;
using std::endl;
class A
{
public:
A ()
{
}
~A()
{
cout << "delete A" << endl;
}
};
class B : public A
{
public:
B () : A()
{
}
~B()
{
cout << "delete B" << endl;
}
};
int main(int argc, char* argv[])
{
B* B_Pointer = new B;
delete B_Pointer;
A* A_Pointer = new B;
delete A_Pointer;
cout << "Press any key to exit" << endl;
::getch();
return 0;
}
This is the output that you will see.
delete B
delete A
delete A
Press any key to exit
The first pointer that is deleted is the object of type B that was stored in a Pointer of type B. Notice how it first calls B's destructor, then A's destructor automatically gets called.
The second object that gets deleted is an object of type B that is stored in an pointer of type A. Only A's destructor will get called.
If you change A's destructor to virtual, this will be the output signifiying that B's destructor properly gets called both times.
delete B
delete A
delete B
delete A
Press any key to exit
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
anyone can tell me how to invoke/reference an ATL COM server from an ASP page?
i am pretty new in this subject, but it'd be nice if u can just get me up to speed here and point me in the right direction.
thanks
norm
|
|
|
|
|
As well as a GUID, your component has a friendly name, such as 'Dundas.Chart'. So you do this in your asp
dim oChart
set oChart = CreateObject("Dundas.Chart")
The COOL thing if you have .NET is that it then gives you intellisense on the objects methods ( just found this out ).
If the component is yours, the friendly name is the name written out in the rgs file, if not, it's in the top hive of the registry, and should be in the docs from the vendor.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
sorry, is this VB.NET syntax? I know VB.NET, but not VB and definitely not VBScript.
but it's an ASP (not ASP.NET) application that'll Create this COM object... and i dont get to decide whether we use ASP.NET or ASP.
and i presume this is the code for an in-process COM server?
Thanks!
norm
|
|
|
|
|
is there any good tutorial on how to create an ATL COM server and reference it from ASP web application?
i am rather overwhelmed by all the reading: ATL, MTA/STA, in-process vs out-of-process, local vs remote, registry APIs, interface and MIDL...
norm
|
|
|
|
|
Dammit - just do what I told you to, and it will work. I've written hundreds of lines of classic ASP, calling COM objects that I wrote to do the business logic. Once you call CreateObject, your variable will be an instance of your COM object, and will have (roughly) the same methods as if you called it from C++. I say roughly, it's actually better - a paramter is set and got as if it was a member variable, without the get_ syntax.
The MSDN is full of examples - start by looking up 'CreateObject'.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
This is VBScript syntax, within an ASP or otherwise.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thanks, just got my ATL-COM-STA local inprocess server runnning and i'm able to consume the service from VC and VB clients.
will try ASP now. havent readup enuf to be sure if an inprocess will be good for our application. i'm still not sure what'd be the threading requirement. just know it will definitely not be DCOM for now.
the application is to generate SQL JOIN logic based on input gathered from an ASP front-end. so, think that many threads will try to access the server at the same time, i think this implies MTA. but i am happy that i can at least get the COM server running and be able to consume the service from ASP for now.
thanks again.
norm
|
|
|
|
|
I've always used this site http://www.learnasp.com/classic/[^] for my ASP problems - pretty much covers everything you'll need.
but like Christian says Server.CreateObject is what you need.
Michael
Life’s not a song.
Life isn’t bliss.
Life is just this.
It’s living. -- Buffy the Vampire Slayer: Once more, with feeling
|
|
|
|
|
I need to retrieve table schema given a table data.
schema information - for a given table - should include:
1. list of columns
2. data type of each column
3. number of records in a table
4. total number of columns
can anyone tell me the API to use for ODBD and ADO to get me up to speed?
Thanks!
norm
|
|
|
|
|
When you use ADO API's to work with database,after you query from that table and fill RecordSet object you can use these methods and properties:
norm wrote:
4. total number of columns
Count property of Fields object.
norm wrote:
1. list of columns
fieldsobject->GetItem(index)->GetName() will return name of EACH column.
norm wrote:
2. data type of each column
fieldsoblect->GetItem(index)->GetType() will do that.
norm wrote:
3. number of records in a table
RecordCount will return number of rows.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
thanks, that's very helpful of u
norm
|
|
|
|
|
How to process the ... in brackets?;P
|
|
|
|
|
How do you mean - that IS how printf is written, isn't it ? CString::Format also works that way, and the source is on your hard drive if you have VC.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
try searching google for va_start, va_arg and va_end.
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
You can use va_arg, va_end, va_start in order to access the arguements that are stored in the ... operator. However, if you are working with C++ and you plan on creating a function that supports a feature like this, it is a lot safer to use iostreams to accomplish this. This will insure that your arguements remain type-safe, which is a major advantage over the C-style implementation.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
char Eofl[]= "\\EndofLine";
char Tab1[] = "\t";
char szItem5[] = "[Underline]";
DDEPoke(idInst, hConv, EndofDoc, szData3);
DDEPoke(idInst, hConv, EndofDoc, Tab1);
DDEPoke(idInst, hConv, Eofl, Tab1);
LPTSTR lpsz = new TCHAR[m_Surname.GetLength()+1];
_tcscpy(lpsz, m_Surname);
DDEPoke(idInst, hConv, EndofDoc, lpsz);
this code is a part of a program which sends data to MS Word using DDE. I manage to find the EndofDoc, Tab,
but cannot find the EndofLine.
if I call the EndofLine it does not send the data to Word.
|
|
|
|
|
i want to creat my own gina dll in order to disable ctrl+alt+del.can any body tell how to creat a gina dll that do nothing when i press ctrl+alt+del and perform all other operation that are performed by the msgina.dll
and how to rplace it with previous dll?
r00d0034@yahoo.com
|
|
|
|
|
Am I the only one who sees two letters prior to gina.dll every time this question is asked ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
Am I the only one who sees two letters prior to gina.dll every time this question is asked ?
nope.
Here's a picture!!![^]
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
Chris Losinger wrote:
Here's a picture!!!
Exactly what I was thinking of as well
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Winlogon and GINA[^]
MSDN: "Winlogon has special hooks into the User32 server that allow it to monitor CTRL+ALT+DEL secure attention sequence (SAS) events. Winlogon makes this SAS event information available to GINAs to use as their SAS, or as part of their SAS. In general, GINAs should monitor SASs on their own; however, any GINA that has the standard CTRL+ALT+DEL SAS as one of the SASs it recognizes should use the Winlogon support provided for this purpose." AND "When Winlogon encounters an SAS event or when an SAS is delivered to Winlogon by the GINA, Winlogon sets the state accordingly, changes to the Winlogon desktop, and calls one of the GINA's SAS processing functions."
This may be of interest to you:
WlxLoggedOutSAS[^]..."The WlxLoggedOutSAS function must be implemented by a replacement GINA DLL. Winlogon calls this function when it receives a secure attention sequence (SAS) event while no user is logged on."
|
|
|
|
|
|
is your computer is on the network?
r00d0034@yahoo.com
|
|
|
|
|