|
Nemanja Trifunovic wrote: And one very important note: static member variables are also really globals, no matter how you call them
Yes, but there are less chances of name clashes with them.
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
|
|
|
|
|
CPallini wrote: Yes, but there are less chances of name clashes with them.
True. Although I prefer using namespaces to avoid name clashes.
|
|
|
|
|
Actually universe isn't such stable...oops, wait a minute, what software are you talking about?
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
|
|
|
|
|
How many times has the value of PI or C or 2^31 or the ASCII char for 'b' changed since you started programming?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
PI precision changes continuosly. 2^31 is a number, i.e. a human brain construct hence it doesn't exist in the universe, c invariance is a rather new concept, ASCII codes, being a mere agreement, have nothing to do with universe.
The universe itself is quickly changing, probably even forgetting about c invariance.
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
|
|
|
|
|
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.
|
|
|
|