|
Let me explain.
Functions would be provided,only when it is needed,
e.g CMap::Lookup gives you fast access to element.
In this case, suppose, there is function long CStringArray::Find(CString strToFind) , returning index of element in array. But, question is, why and how often that index will be needed ?
And you answer, that it will be useful for faster access ,etc. Then there are other datastructure, which are more efficient doing this.
The reason could be, just keep this class simple, not adding overhead to it.
|
|
|
|
|
OK - you mean to say that if I do a lot of searches, then an indexed container would be an ideal candidate. That's the same exact thing I thought. But nevertheless, it was shocking to me that MS hasn't provided a find on CStringArray.
Thanks for the reply man, I appreciate it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
INT, INT32, LONG and LONG32 all are 32-bit signed integer.
Then what is the main difference among them?
Also I have saw other many similar data types (e.g LONGLONG, LONG64.
What is the need of this difference?
Any one please describe about it.
Regards
Maxim
|
|
|
|
|
This would be compiler and platform dependent.
Regards,
Sandip.
|
|
|
|
|
I dont think so. All are used in VC++ on same compiler(VS 2005) and same platform(Windows).
Please describe the difference.
By the way, Thanks for your effort.
|
|
|
|
|
see int and long both will be 4 bytes each on windows(VC++). but still they are kept as is may be for backward compatibility.
If you really want the difference try to find sizes for these data types on all the windows versions for above then you will get an idea.
Regards,
Sandip.
|
|
|
|
|
Please tell me about all not only two. Also, I want to know about INT, INT32, LONG, LONG32 not int and long. If you can, please compare atleast these four data types.
Regards,
Maxim.
|
|
|
|
|
Have you problems with documentation?
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
|
|
|
|
|
No, not at all. But I am little bit confused.
I am just curious to know the difference among them on same windows version with same compiler.
I am talking about their uses and importance also need. I have used all in my program and not found any difference. That is why I am asking here.
Because you all are experienced and experts.
Please guide me.
Sorry, If i am wrong or rude anywhere.
Regards,
Maxim.
|
|
|
|
|
Sir, Can I know the reason of down voted?
Is my way of asking question is not right?
I am new here in this forum. I was just trying to explain me before all of you...
Thanks.
Maxim.
|
|
|
|
|
I can only guess (since I didn't down vote you): possibly your post appeared a bit rude.
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
|
|
|
|
|
i am trying to tell you only one thing is today there might not be any difference but still these will be kept as is for compatibility.
Tomo with vista and 64bit machines coming in , int , long, int64 all might have 64 bit values but still they will be maintained different for compatibility.
Regards,
Sandip.
modified on Monday, June 2, 2008 8:03 AM
|
|
|
|
|
SandipG wrote: Tomo with vista and 64bit machines coming in , int int32 int64 all might have 64 bit
if int32 have 64 bit then it is meaningless.
|
|
|
|
|
|
I will change my reply but i am not saying it i just took it as an example.
Regards,
Sandip.
|
|
|
|
|
Helpful link. Thanks.
And your answer is also very supportive.
Giving you 5 votes...
|
|
|
|
|
The difference on the windows platform isnt there, but if you use the source-code on other platforms or other compilers than from MS there 'maybe' differences.
But LONGLONG, LONG64 are resolved to 64-bit data on WIN64 so there can stroe 64-bit data!!!
Greetings from Germany
|
|
|
|
|
Hi
When clicks on View, my program draws ellipse and I tried to make all changes in one view reflects to all views.
1-)OnLbuttonDown adds a point to CArray m_PointList
2-)UpdateAllViews calls OnUpdate
3-) OnUpdate Invaliates so OnDraw called.
void CDocumentView::OnLButtonDown(UINT nFlags, CPoint point)
{
GetDocument()->m_PointList.Add(point);
GetDocument()->UpdateAllViews(NULL);
CView::OnLButtonDown(nFlags, point);
};
void CDocumentView::OnDraw(CDC* pDC)
{
CDocumentDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
for(int i = 0; i < GetDocument()->m_PointList.GetCount(); i++)
{
pDC->Ellipse(GetDocument()->m_PointList[i].x - GetDocument()->m_PointSize,
GetDocument()->m_PointList[i].y - GetDocument()->m_PointSize,
GetDocument()->m_PointList[i].x + GetDocument()->m_PointSize,
GetDocument()->m_PointList[i].y + GetDocument()->m_PointSize);
}
}
void CDocumentView::OnUpdate(CView* , LPARAM , CObject*
)
{
Invalidate();
}
But when i open a new document, it doesn't draw ellipse which is m_PointList , it shows a clean view window. And when i started to click also it doesn't change the other views.
Where am i wrong?
|
|
|
|
|
If you open a new dicument contents of m_PointList will be changed ,isn't it?
because you will be having new docuemnt class pointer.
Regards,
Sandip.
|
|
|
|
|
Sorry;
When i clicked File->New (Ctrl+N).
My CArray m_PointList is in the document file (DocumentDoc.h).
For every new view, same doc file using, right? Same m_PointList?
But something wrong and i can't find it.
|
|
|
|
|
its not about using same document.h file.
everytime new instance of CDocuemnt will be created when you do ctrl+N
so every time m_PointList will have default values.
Regards,
Sandip.
|
|
|
|
|
What?
If so,
But why do we call updateallviews? Isn't that for all the views that created with Ctr+N?
Isn't that advantage of Doc/View architecture, One Document and multiple views?
I am really surprised.
|
|
|
|
|
Listen UpdateAllView is for updating All views associated with one instance of document. (not the views associated with different instances of documents.)
Consider TreeView1 ListView1 both are associated to docuemnt1.
Now when you call UpdateAllViews for docuement1 then Treeview1 and listview1 will be updated.
Regards,
Sandip.
|
|
|
|
|
I agree with Sandi, you are creating new documents, so you will have new pairs Doc-View and the new ones have nothing to do with the old ones.
If you DO want to have only one document and more views... take a look here[^]
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi everyone, I've been trying to make a simple password generator such that when i enter a number and click generate, a random string of
alphanumeric characters is generated. my problem is every time i click generate, only 1 letter seems to appear. Any help will be greatly appreciated. Source code is as follows:
#include <windows.h>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include "resource.h"
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
SetDlgItemInt(hwnd, ID_PASSWORD,1, FALSE);
case WM_COMMAND:
switch(wParam)
{
case ID_GENERATE:
{
char alpha[80]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
char passwrd[80]="";
int numChars = GetWindowTextLength(GetDlgItem(hwnd, ID_PASSWORD));
if(numChars > 0)
{
// Now we allocate, and get the string into our buffer
srand(static_cast<unsigned>(time(0)));
for (int n=0; n<numchars; n++)<br="" mode="hold"> {
int x;
x = 0 + int(61.0 * rand()/(RAND_MAX+1.0));
passwrd[n]= alpha[x];
}
This is the main problem -----------------> MessageBox(NULL, passwrd, "Word Generated", MB_OK);
int index = SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)passwrd);
GlobalFree((HANDLE)passwrd);
}
else
{
MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);
}
}
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
default:
return FALSE;
}
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc);
}
|
|
|
|
|