|
zhoujun wrote:
In a book I have just read said "Tdate td()" is not allowed.
As Joaquín also pointed out, that is correct; i was wrong. (i guess i should probably stick to sleeping at 2:00am...)
new Tdate;
is equivilant to
new Tdate();
however.
zhoujun wrote:
In VB,what is the difference of the following three:
Dim td as new Tdate();
Dim td as new Tdate;
Dim td as Tdate;
The first one declares an array, but gives it no initial size (parentheses are used for arrays as well as function calls in VB)
Actually, i'm not possitive that the first line will work; the syntax seems a bit odd, even for VB, as new is used to instantiate objects, but as the array is initially empty, there is nothing to instantiate.
The second one declares and instantiates a Tdate object.
The third one declares, but does not instantiate a Tdate object; it will need to later be instantiated using new or CreateObject() .
Generally in VB6 the use of new in a declaration line is discouraged, as though it's function is to instantiate an object, it does not actually do so until it is first used, at which point it is difficult to gracefully handle failures. In VB.NET, this has been corrected.
(The VB forum would probably be the place to get more confident answers to VB questions...)
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
Unfortunately, Tdate td; and Tdate td(); are not equivalent. The latter, as the original poster rightly pointed out, is interpreted by the compiler as the declaration of a function with no arguments returning a Tdate , regardless of the context. It is a quirk of the language we have to live with
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ooops! Thanks Joaquín; not sure what i was thinking last night...
Shog9
------
And on the pedestal, these words appear:
"My name is Ozymandias, King of Kings,
Look on my Works, ye Mighty, and despair!"
Nothing beside remains.
|
|
|
|
|
Hi,
with regard to UrlEscape function, why do I get "'UrlEscape' : undeclared identifier" when I compile?
I do have the required version of "Shlwapi.dll".
I am running on Win2000.
Kindly Help.
Thanks,
John.
|
|
|
|
|
It's declared in shlwapi.h (5.0 and higher).
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I am programming with MSVC++ 5.0 and 6.0. Interestingly the Shlwapi.dll offers the UrlEscape function, but is not declared in the file Shlwapi.h as posted by Stephane. Perhaps you need the latest SDK.
|
|
|
|
|
Yes, download the Platform SDK[^]. Or buy VC7.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Now, I've created a control by subclassing it from CStatic.
The thing is :
I wanna place this control on a dialog, and when the user right-click on a certain spot on this control, a pop-up menu should show up.
The problem is : although this subclassed control exposes/supports the WM_RBUTTONDOWN message within it's class, when I wanna use it from the main dialog, ClassWizard shows only the BN_CLICKED message!
Of course, I can add the WM_RBUTTONDOWN message handler to the main dialog class and test if the right mouse button was clicked within this subclassed static control, but the fact is : this message isn't being sent!
I mean, yes. It is sent when I right-mouse click outside the subclassed control, but when I right-mouse clicked inside the control, this WM_RBUTTONDOWN message isn't being sent, so this approach is useless.
I've added the SS_NOTIFY style to this subclassed control, but useless either.
What I wanna do is to "force" this subclassed static control to expose the WM_RBUTTONDOWN message handler, just like the way the BN_CLICKED message handler of this sub-classed static control is exposed. Does anyone have any ideas? Please and thanks a lot!
......
|
|
|
|
|
If nothing else, you can add it to the message map manually using ON_MESSAGE .
Gary R. Wheeler
|
|
|
|
|
Hi.
I am studying more advanced C++ via Scott Meyer's Effective STL. I have not read any of his previous books including the C++ series. He does an exceptional job introducing invaluable advices on the use of STL. I am still reading it.
He makes references to a term that I am not familiar with. He mentions "reference counting" about vector and string containers. What is it?
Thanks,
Kuphryn
|
|
|
|
|
That means that every time you assign or copy a string, the string object does not copy the character data, instead it increments a count that keeps track of how many objects are using its buffer. For example:
string s1 = "foo";
string s2 (s1);
string s3;
s3 = s2; After making those three strings, there is only one copy of "foo" in memory, and all 3 string objects point to it. The string class only copies the character data if you modify a string, such as:
s3 += "bar";
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I have a quickie question for you:
On modern machines, especially with the memory typically available, how big a difference does it make to have a string class reference counted? Is it truly worth all the effort that goes into making the refcounting work correctly in all situations?
Just curious
¡El diablo está en mis pantalones! ¡Mire, mire!
|
|
|
|
|
Yes depending on the circumstances. I can think of two scenarios where a string class with these features helps out.
Picture very large strings that are copied and moved around. I think there would be a very good increase in space and time savings.
Also think of a case where you will have a string that gets repeated 1000's of times. For instance an XML file that contains a set of records for peoples names, and the "name" tag is repeated over and over. Or even a home grown version of a large array of structs where the default entry is "default". New memory would only get allocated for the default string when the user changed the value.
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!
|
|
|
|
|
Jim Crafton wrote:
On modern machines, especially with the memory typically available, how big a difference does it make to have a string class reference counted? Is it truly worth all the effort that goes into making the refcounting work correctly in all situations?
Oh, and it's not all about memory performance: Speed performance can be much improved with reference counting or COW (copy on write). It's much faster incrementing a counter than moving large blocks of memory; and still, in modern machines you can imagine building a typical dynamic HTML page at a server and you'll start seeing strings with 20k, 50k, 100k being moved around back and forward. This makes a great difference.
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
reference counting is where you keep track of how many variables hold a reference to a particular pointer.
Each time you set a variable to point to a pointer that is reference counted, you increment the reference count. Each time that variable is done with your object, and no longer uses that pointer, you decrement the reference count.
When the reference count reaches 0, it is safe to delete that pointer because nobody else is referencing that object.
Reference counting has become a very popular technique in safely managing dynamic memory when more than one object needs to hold a reference to a pointer.
COM uses reference counting extensively to manage its interface pointers.
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!
|
|
|
|
|
Okay. Thanks everyone.
Kuphryn
|
|
|
|
|
I wanted to display 10 bitmaps using CImageList
but why all the bitmaps were black
1.first ,I created a project "Cards",Imported 1,2,...,10
2.and I added variable in CCardsView
CImageList* m_pImageList
and the function
BOOL CCardsView::AddBitmap(UINT nResourceID)
{
CBitmap m_bmp;
if(m_bmp.LoadBitmap(nResourceID))
{
m_pImageList->Add(&m_bmp,RGB(256,256,256));
m_bmp.DeleteObject();
return TRUE;
}
return FALSE;
}
3.CCardsView::CCardsView()
{
// TODO: add construction code here
m_pImageList=new CImageList;
m_pImageList->Create(71,96,ILC_COLORDDB,256,1);
for(int i=1;i<11;i++)
{
AddBitmap(i);
}
}
4.CCardsView::~CCardsView()
{
if(m_pImageList!=NULL)
{
delete m_pImageList;
}
}
5.void CCardsView::OnDraw(CDC* pDC)
{
CCardsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPoint pos(0,0);
// m_pImageList->SetBkColor(CLR_NONE);
// m_pImageList->SetOverlayImage(0,1);
for(int i=0;i<10;i++)
{
m_pImageList->Draw(pDC,i,pos,ILD_NORMAL);
pos.x+=50;
}
}
Why?
--oly--
|
|
|
|
|
<quote>
m_pImageList->Add(&m_bmp,RGB(256,256,256));
This might be a problem. Try to change it to RGB(0,0,0),
|
|
|
|
|
I have tryed
but it did not work
|
|
|
|
|
<br />
BOOL CCardsView::AddBitmap(UINT nResourceID)<br />
the above method take in ResourceID!! but you said
for(int i =1; i<11; i++)
AddBitmap(i)
check whether i is the appropriate resource name!!!!
|
|
|
|
|
yeah
I added 10 bitmaps with id 1 to 10
what is the matter?
|
|
|
|
|
if u want i can have look at your code!!! Send it to my email.!!
|
|
|
|
|
but I have wrote it down in my question
pls help me
It has puzzled me for 3 days
and no one could give me a correct answer
--oly--
|
|
|
|
|
You must pass the resource ID to AddBitmap , not the index of the bitmap. The resource ID will be found in resource.h .
Gary R. Wheeler
|
|
|
|
|
Hi
I'd like to get the user's input from the console, if the user put in some text, this information will be put in a buffer, if the user type in nothing in and press enter then the program is terminated. But how do i know if the user has type in something???
i've attempted to play around with this, first with cin.getline, cin.get ...and finally come up with gets(), however it still seem has not done the job.
this is the code that i've attempted
<br />
char input[MAX_PATH];<br />
char *pInput = input;<br />
<br />
cout << "Enter the text " << endl;
<br />
char delimeter =(char)gets(input);
<br />
while( delimeter != '\r' )<br />
{<br />
<br />
<br />
cout << "Enter the text " << endl;<br />
delimeter =(char)gets(input);<br />
}<br />
<br />
Any ideas, helps or suggestions are highly appreciated!!!
Regard,
|
|
|
|
|