 |
|
 |
Note to myself – use the refresh button before posting!
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
 |
|
 |
PIEBALDconsult wrote:
That's like saying you can't differentiate the accelerator from the gas peddle.
I can see what you're staying, but given a pointer, you can't tell whether it's pointing to a single item, or to the beginning of an array of items.
And because arrays are passed to functions as pointers, you need to pass the length of the array as well.
|
|
|
|
 |
|
 |
S. Senthil Kumar wrote: And because arrays are passed to functions as pointers, you need to pass the length of the array as well.
Or in case of char array you can rely on the zero terminator, which gives you a fairly good chance either to lose some data or to loop through the entire computer memory.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
 |
|
 |
They're basically two terms for the same thing and the machine doesn't care what you call it.
|
|
|
|
 |
|
 |
Jim Crafton wrote: nor is there a way to distinguish an array from a pointer
IMHO – because there is no deference.
unsigned char v1;
unsigned char v2;
char arr[] = {'A', 'B', 'C'};
v1 = arr[1];
v2 = *(arr+1);
char *str_arr = "ABC";
v1 = str_arr[1];
v2 = *(str_arr+1);
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
 |
|
 |
Deyan Georgiev wrote: IMHO – because there is no deference.
There is a difference - compare sizeof for arr vs str_arr (and in fact the size of array *can* be determined it is sizeof(arr)/sizeof(char) in your case). The problem is so-called array decay[^] where, for instance an array cannot be a function argument - the pointer gets silently passed instead.
|
|
|
|
 |
|
 |
Yes you are right and i know this limitations. But what I was trying to say is that you can use the same syntax with the both pointers and arrays.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
 |
|
 |
There are enough nice things in C++0x, that I'll use them when I'm able (due to run times on the devices I support, I'm still using VC++ 6.0 for most of my work), but some of this stuff really annoys me. The leading contender is not using the keyword foreach for the, well, foreach feature (this one is so dumb, I still can't figure out what they were thinking.)
There are other things that while nice, I have a real problem with from a lean and mean perspective; the improved copy semantics do improve resizing an array of classes, but who makes resizeable arrays of non-trivial classes? I gave that up a few hours into learning C++, favoring arrays of pointers in this situation. Apparently I'm not alone since I can't remember the last time I saw this in real-world code.
(I'm also not a big fan of Boost or STL and dislike them being part of the base language.)
As for the length of an array; this has baffled me for a long time since the underlying construct "knows" what it is. Even C should have had the ability to readily get the length of a malloc'ed block.
And it still doesn't solve the problem of having a switch inside a loop and having to exit both without resorting to a bool or something comparable. (In other words, using the keyword "break" for ending case statements wasn't a very good idea. [Of course, while griping about this, what the heck were the C# people thinking by requiring the stupid keyword?])
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
 |
|
 |
Joe Woodbury wrote: using the keyword "break" for ending case statements wasn't a very good idea
I agree, it's one of the things I'll tell dmr when I get my time machine working. That and that the assignment operator should be :=.
But it still won't help breaking out of an inner nested loop.
|
|
|
|
 |
|
 |
PIEBALDconsult wrote: the assignment operator should be :=.
Even before I learned C, but had a PASCAL class, I hated that.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
 |
|
 |
I never minded it in Pascal, just was glad I wasn't doing BASIC anymore.
It only matters in C and its offspring.
It seems that C's grandparent, BCPL, also used := for assignment, but Ken Thompson reverted to = for B.
|
|
|
|
 |
|
 |
There is some really cool stuff I am looking forward to, some cool stuff that I am afraid of, and then there are user defined string literals.
First and second view, that's serious suckage. It's both powerful and insanely limited at the same time. The only nice thing about it: it might be a minor step towards compile-time C++ - at least for simple stuff.
|
|
|
|
 |
|
 |
Wow. I've just participated in conversations on both topics, and the dialog is even polite, respectful and civil.
Is Rod Serling hiding in my closet somewhere?
|
|
|
|
 |
|
 |
Christopher Duncan wrote: Is Rod Serling hiding in my closet somewhere?
Why are you asking us? You should remember where you hid the body ...
|
|
|
|
 |
|
 |
Given that I don't even remember the 70s, that's highly unlikely.
|
|
|
|
 |
|
 |
Christopher Duncan wrote: Given that I don't even remember the 70s, that's highly unlikely.
Emmm ... there are a few cold cases we'd like to ask you about ... We'll need a blood and hair sam ... oh sorry ...
|
|
|
|
 |
|
 |
Ouch, that's pulling him up by the short hairs... oh wait...
|
|
|
|
 |
|
 |
Jim Crafton wrote: that's pulling him up by the short hairs.
I don't even WANT to know where he's going to pull those from ...
|
|
|
|
 |
|
 |
He lived through the 70's and he's a musician - he's lucky if he can remember his name at the end of the day
|
|
|
|
 |
|
|
 |
|
 |
"Politics and Religion", the combination is forbidden by the secularity laws in civilized countries, yet there are "religiously tainted political parties". Does that make sense to you? Not to me.
|
|
|
|
 |
|
 |
Hey, I think it makes sense to write programs in an operating system rather than a web browser, so clearly I'm not a realistic point of reference.
|
|
|
|
 |
|
 |
Is it truly possible to expect someone who's deeply religious to keep that perspective out of their political practice? After I typed that... if I was elected to any office I'd try my hardest to do that very thing so yes I do believe it's possible. You are right to question that the way you have.
|
|
|
|
 |
|
 |
Christopher Duncan wrote: Wow. I've just participated in conversations on both topics, and the dialog is even polite, respectful and civil.
Now you can raise the bar and ask a VB programming question in the Lounge.
|
|
|
|
 |
|
 |
I think that the recent and massive shift from Bush (whom I loved) to Obama (whom I just really don't understand) has forced us all to set aside to some degree politics and political affiliations and to realize that if we don't start fixing some of our core rights, and protecting them fiercely for *EVERYONE* who lives here then our country will rip apart and die. I think all of us need to realize that right now our country teeters precariously upon the edge of a cliff and only people can fix the problems. We are asking way to much of our elected officials and I'm only just now realizing it. Why did Bush seem to fail and why when it's over will many think Obama did too? It's because we expect them to do all of the fixing while we watch from the side and call "fair play" or "foul ball" from the quagmire of indecision that has become the life of the individual American life.
I hope more American's are beginning to see what I'm starting to see.
i. If I don't fight tooth and nail to make sure your constitutional rights are protected you will not fight tooth and nail to protect mine. If I fight for yours it's selfless if I fight for mine it's selfish. Nobody wins and it's never enough when we pursue our own interests.
ii. I think homosexuals would better understand how to protect the rights of peaceful Christians than even Christians do and I think they should organize and try to do that very thing. I think that Christians should set aside their own interest and tackle the problems that homosexual people face and fight incredibly hard to solve those problems and help them. In doing so both sides would learn the truth about each other. That truth is really they are not nearly as different as they thought.
America would grow and prosper if democrats fought for the republican interests as hard as possible so they could be rewarded by seeing republicans fight tooth and nail for the rights of democrats. Each of them trying to one-up the other in fighting for their opposites rights. That I'm learning is what being American really is.
|
|
|
|
 |