|
this is not what i'd call a OO solution , though
|
|
|
|
|
Of course. I'm here just for that.
You don't recall our agreement:
You give OO solutions.
I give the (OOP) misleading ones.
Do you?
BTW I agree with Nemanja Trifunovic:"static member variables are also really globals, no matter how you call them". Static member variables are dressed up globals.
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
|
|
|
|
|
but I got a vote '3' for preventing a newbie to use global variables ?!
|
|
|
|
|
My friend you worry too much about votes. Anyway you got my five to balance a bit.
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
|
|
|
|
|
there some code like:
int a[] = {1,2,3,4,5};
int* ptr = (int*)(&a+1);
printf("%d\n",*(ptr-1));
i know,the name of a array(here is a) is a const point. So,&a should be a point of a,its type should be int**. But,why ptr-1 point the last element of the array?It seems a little strange!
Regards.
|
|
|
|
|
A few weeks ago we had a q&a with g_g about this.
Someone (I think David Crow) pointed out that the pointer to an array is the array itself.
Odd, but true.
int a [] = {1,2,3,4,5};
int *p;
p = a;
&a is a int [] still, but &p is an int **.
It is is bizarre, but an early example of a compatibility hack, to help things like scanf, printf, etc.
While I may not be putting this perfectly well, just accept this is a rare quirk of C, shrug and move on.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
but i still puzzled why &a remains to be a int[]?
of course a do is,but why &a?
|
|
|
|
|
See also here [^].
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
|
|
|
|
|
yeah.that says a == &a is true.
but why the out put will 5?
maybe in &a+1,it treat the array as one variable,so &a+1 will jump the entire array to the end of the array? if right,all the thing become easy,i will understand too.
Thanks
|
|
|
|
|
kcynic wrote: but why the out put will 5?
because of pointer arimethic: sizeof(a)== 5 * sizeof(int) , hence &a+1 == ((int*)&a)+5 .
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 see it now.Thanks very much.
|
|
|
|
|
kcynic wrote: int a[] = {1,2,3,4,5};
int* ptr = (int*)(&a+1);
kcynic wrote: So,&a should be a point of a,its type should be int**.
no, &a is of type int (*)[5], not int **. Othercase is Don't think int ** and int [][], multi dimensional array are same the former stores pointer to some different location while later stores in values in contigious location.
kcynic wrote: But,why ptr-1 point the last element of the array?
so, &a is of type int (*)[5], (not int **), so incrementing a pointer increments based on the type, so (&a + 1) actually points next to the enter size of array; since that is the type, int (*) [5].
so ptr - 1 points to last element.
i repeat int (*)[5] is not same as int **, you can ensure this by trying the following code,
int *ptr = (int *)(((int **)&a) + 1);
|
|
|
|
|
|
Hi,
At present i was assigned a work of preparing an application that to support multilingual interface.
It is expected to support many languages esp, chinese, japanese etc.
It would be helpful anyone guide me...
Thanks in advance,
Ganesh
Thanks a lot
|
|
|
|
|
Is your application Unicode aware at first? Don't ask me what Unicode is.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have some idea about unicode...can you give me any samples or links that help me to know better.
Thanks in advance.
Thanks a lot
|
|
|
|
|
You still haven't answered my question. Is your application Unicode aware?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi
Thanks for ur response!
No, in Project settings C/C++ Tab-> Project options -> it was set "_MBCS" , therefore i guess it is not aware of unicode.
Please guide me!
Thanks a lot
Thanks a lot
|
|
|
|
|
So, you guessed it right. Replace _MBCS with _UNICODE. Do that, and try compiling. You'll hit a dead end and then start reading on Generic text mappings. But, fortunately for you, if the project already is following Generic text mappings, then you could easily proceed by installing the language scripts that you plan to use, and then get on with your project. I say, you have a long way to go. But go step by step and it isn't very difficult.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
This statement doesn't give you too much hope
"I have some idea about unicode..." holy cow, it's time to leave the room.
|
|
|
|
|
But usually I give them a try. Some people just pick it up right off. And if they don't, I do leave the room.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have some idea about unicode...can you give me any samples or links that help me to know better.
Thanks in advance.
Thanks a lot
|
|
|
|
|
What OS versions are you targetting? WinCE (3.x, 4.x, 5.x, 6.x), Win9X, Win NT/2000/XP/Vista, Server 2K, Server 2003, Server 2008.
This will probably the biggest determining factor in how you go about this job.
What features do you want in multi-languages, fixed text display, variable text display generated from numeric values or network messages, variable text display generated from user input in a single fixed language, variable text display generated from user input directly in variable languages requiring IME (Input Method Editor) support.
You want Chinese and Japanese support and presumably English but do you want Arabic or Hebrew RTL (Right To Left) laguage support.
Do you need to support SIPs (Software Input Panels) or merely different keyboard layouts?
Each of these levels of requirements will likely change the way you need to do things, which technologies you need to incorporate and how hard the task is.
Are you starting the project from scratch of upgrading an existing single language code base?
Do you use any 3rd party components, especially in the UI and can they support the languages you want?
Last but not least get some good books on Internationalization (I18n) and add www.unicode.org to you browser favourites. Good Luck.
P.S. if this is a substantial application running on multiple Os version then clear a year in your schedule.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Target OS: Win XP,
It is expected to deal with variable text display, and to support arabic also, i need SIP. Already i am in the middle of the project and i need to add these features, perhaps i may be needed to create controls from scratch.
Please help me how to proceed.
Thanks
Thanks a lot
|
|
|
|
|
NO U Need not Create all the interfaces once again.
U Just need to Give id to all the Controls and load them using
Resource Dll.
<br />
<br />
inline HINSTANCE LoadResourceDll()<br />
{<br />
<br />
HKEY hkey;<br />
unsigned long no = 2048;<br />
DWORD pos;<br />
BYTE strRegValue[2048] = "\0";<br />
CString csLanguage = _T("");<br />
CString csDllPath;<br />
wchar_t *pwcDllPath = NULL;<br />
HINSTANCE m_hResInstance = NULL;<br />
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("Path to ur registered application"),0,_T("Registration"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hkey,&pos) == ERROR_SUCCESS)<br />
{<br />
if( RegQueryValueEx(hkey,_T("CurrentLanguage"),NULL,NULL,strRegValue,&no) == ERROR_SUCCESS) <br />
{ <br />
csLanguage = (wchar_t*)strRegValue ;<br />
csLanguage.TrimLeft();<br />
csLanguage.TrimRight();<br />
}<br />
<br />
}<br />
TCHAR lpBuffer[1028];<br />
GetSystemDirectory(lpBuffer,1028);<br />
csDllPath = (LPCTSTR) (const char*) lpBuffer;<br />
csDllPath.TrimLeft();<br />
csDllPath.TrimRight();<br />
if (Encrypt(_T("ENG")) == csLanguage)<br />
csDllPath+= "\\DUresENG.dll";<br />
else if (Encrypt(_T("JPN")) == csLanguage)<br />
csDllPath+= "\\DUresJPN.dll";<br />
else<br />
csDllPath+= "\\DUresENG.dll";<br />
<br />
m_hResInstance = LoadLibrary(csDllPath);<br />
<br />
<br />
return m_hResInstance;<br />
}
And In ur .Cpp
Call Controls like this, Call all controls in one Function. call them in OnInitDialog of Ur Dialog Class.
void CAttributeProperties::SetDialogLabels()
{
m_csLabel = LoadResourceString(m_hResInstance ,AfxGetApp()->m_hInstance,1);<br />
GetDlgItem(IDOK)->SetWindowText(m_csLabel);
}
And call them in OnInitDialog of Ur Dialog Class.
BOOL CAttributeProperties::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
<br />
SetDialogLabels();<br />
}
|
|
|
|
|