http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* a problem about "sqrt" - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a2084ac75a5823f4?hl=en
* Electronics - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/14baa777c3867ffa?hl=en
* C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression" - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
* The C++ Object Model: Good? Bad? Ugly? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/6e3c894e0875a337?hl=en
* elementary string processing question - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/5477a6698fdf8341?hl=en
* Strooustrup - Hello World exercise - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/082118a58f35476a?hl=en
==============================================================================
TOPIC: a problem about "sqrt"
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a2084ac75a5823f4?hl=en
==============================================================================
== 1 of 3 ==
Date: Fri, Oct 31 2008 6:23 pm
From: linlinfan320@163.com
why it print wrong result? I can't find the wrong place.
#include<stdio.h>
#include<math.h>
double distance(double a ,double b,double c,double d);
int main()
{
double x1,y1,x2,y2;
double result;
printf("Enter four numbers:");
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
result=distance(x1,y1,x2,y2);
printf("The distancd is %.1f",result);
return 0;
}
double distance(double a,double b,double c,double d)
{
return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
== 2 of 3 ==
Date: Fri, Oct 31 2008 6:54 pm
From: Kai-Uwe Bux
linlinfan320@163.com wrote:
>
> why it print wrong result? I can't find the wrong place.
>
>
> #include<stdio.h>
> #include<math.h>
>
> double distance(double a ,double b,double c,double d);
>
> int main()
> {
> double x1,y1,x2,y2;
> double result;
>
> printf("Enter four numbers:");
> scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
Print the values of x1, x2, y1, and y2 here.
Are they, what you expect?
> result=distance(x1,y1,x2,y2);
>
> printf("The distancd is %.1f",result);
>
> return 0;
> }
> double distance(double a,double b,double c,double d)
> {
Or, print the values of a, b, c, and d here. E.g.:
std::cout << a << " " << b << " " << c << " " << d << "\n";
> return sqrt((a-c)*(a-c)+(b-d)*(b-d));
>
> }
Best
Kai-Uwe Bux
== 3 of 3 ==
Date: Fri, Oct 31 2008 7:12 pm
From: "osmium"
<linlinfan320@163.com> wrote:
> why it print wrong result? I can't find the wrong place.
>
>
> #include<stdio.h>
> #include<math.h>
>
> double distance(double a ,double b,double c,double d);
>
> int main()
> {
> double x1,y1,x2,y2;
> double result;
>
> printf("Enter four numbers:");
> scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
The penalties for lying to the I/O routines are often severe.
>
> result=distance(x1,y1,x2,y2);
>
> printf("The distancd is %.1f",result);
>
> return 0;
> }
> double distance(double a,double b,double c,double d)
> {
> return sqrt((a-c)*(a-c)+(b-d)*(b-d));
>
> }
==============================================================================
TOPIC: Electronics
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/14baa777c3867ffa?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Oct 31 2008 6:19 pm
From: Sjouke Burry
swapu wrote:
> Electronics is the field of manipulating electrical
Multyposting nincompoop fishing for ad clicks.
== 2 of 2 ==
Date: Fri, Oct 31 2008 6:30 pm
From: Ian Collins
Sjouke Burry wrote:
> Multyposting nincompoop fishing for ad clicks.
Why repeat it here? Decent severs have filtered out the original.
--
Ian Collins
==============================================================================
TOPIC: C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression"
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Oct 31 2008 7:18 pm
From: Keith Thompson
Hendrik Schober <spamtrap@gmx.de> writes:
> vippstar@gmail.com wrote:
>> On Oct 31, 10:56 am, Hendrik Schober <spamt...@gmx.de> wrote:
>>> Keith Thompson wrote:
>>>> Hendrik Schober <spamt...@gmx.de> writes:
>>>>> Keith Thompson wrote:
>>>>>> "robertwess...@yahoo.com" <robertwess...@yahoo.com> writes:
>>>>>>> Frankly I think ranges on the case constant expressions would be a
>>>>>>> more useful addition while staying with the basic philosophy of the C
>>>>>>> switch statement. IOW, "case 2...5:", or something along those
>>>>>>> lines. But still not something I'm loosing sleep over...
>>>>>> Then programmers will inevitably write
>>>>>> case 'A' ... 'Z':
>>>>>> which is non-portable (under EBCDIC it matches '\' and '}').
>>>>> And why exactly would that be worse than an 'if'-'else' chain
>>>>> relying on ASCII?
>>>> It wouldn't. [...]
>>> Then I don't see how your above argument is valid.
>> [...]
>> My interprentation:
>> He says that adding such syntax, .., would introduce more newbie
>> pitfalls in the language, because most people would expect 'A' .. 'Z'
>> to mean all the uppercase letters, where it could mean anything.
>
> And wouldn't those be the people who now use 'if' to
> do exactly the same?
Probably. But my point, one more time, is that this feature would, in
this particular case, make it *easier* to write bad code (i.e., code
that assumes 'A'-'Z' are contiguous) without making it any easier to
wrote good code (i.e., code that avoids that assumption by using
isupper(), which can't be used in a case expression).
Suppose you're maintaining some code that uses
case 'A' ... 'Z':
and you want to make it more general. You'll have to restructure the
code, using an if statement rather than a switch statement.
On the other hand, if the code you're maintaining uses the equally
non-portable:
if ('A' <= c && c <= 'Z') ...
then it's much more straightforward to change it to:
if (isupper(c)) ...
or perhaps
if (isupper((unsigned char)c)) ...
I'm not saying this is an ironclad argument against adding such a
feature, just that it's a (possibly) significant issue that should be
considered.
>> My view on it: Syntactic sugar that would only complicate the
>> language(s) further without being a real convenience.
On the other hand, it *could* be a real convenience when you need
numeric ranges. It would also be perfectly ok for '0' ... '9', or
even for 'A' ... 'Z' if portability isn't a high priority.
> I'm not a string proponent of the feature. I just don't
> see the validity of this argument against this.
> Any feature added to the language will open new ways to
> abusing. If that by itself was an argument against new
> features, we wouldn't have had any features at all.
Sure, any feature can be abused; the problem is that this feature
makes certain kinds of abuse easier without making the corresponding
non-abuse any easier.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
==============================================================================
TOPIC: The C++ Object Model: Good? Bad? Ugly?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/6e3c894e0875a337?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Oct 31 2008 8:02 pm
From: tonytech08
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).
What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.
So, I'm more than leaning toward "bad" because of the limitations and
that the language doesn't distinguish what is of very key importance.
How do you feel about the object model?
==============================================================================
TOPIC: elementary string processing question
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/5477a6698fdf8341?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Oct 31 2008 8:28 pm
From: tonywh00t
Hi everyone,
I have a "simple" question, especially for people familiar with regex.
I need to parse strings that have the form:
1:3::5:9
which indicates the set of integers {1 3 4 5 9}. In other words i have
a set of numbers separated by ":", where "::" indicates a range from
lo to hi inclusive. It is desirable to error check this string (i.e it
should. start and end with a number, and be composed only numbers,
"::", and ":"). I'm currently using the Boost C++ library, and i've
worked out some pretty ugly solutions. If anyone has a suggestion, I'd
very much appreciate it. Thanks!
==============================================================================
TOPIC: Strooustrup - Hello World exercise
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/082118a58f35476a?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Oct 31 2008 9:07 pm
From: blargg.h4g@gishpuppy.com (blargg)
In article
<491f5749-f52b-4614-ab2d-83e0741be7b1@k36g2000pri.googlegroups.com>,
gw7rib@aol.com wrote:
> On 30 Oct, 20:41, arnuld <sunr...@invalid.address> wrote:
> > How about this:
> >
> > #include <iostream>
> >
> > class Useless
> > {
> > public:
> > =A0 Useless() =A0{ std::cout << "Initialize" << std::endl; }
> > =A0 ~Useless() { std::cout << "Clean up" =A0 << std::endl; }
> >
> > };
> >
> > Useless obj_of_useless;
> >
> > int main()
> > {
> > =A0 std::cout << "Hello World!" << std::endl;
> >
> > =A0 return 0;
> >
> > }
>
> Yes, that looks just the sort of thing they were after.
Unlike this questionable solution that defines no new classes:
#include <iostream>
#include <cstdlib>
namespace
{
void cleanup() { std::cout << "Clean up\n"; }
int init = (std::cout << "Initialize\n", std::atexit( cleanup ));
}
int main() { }
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en
To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
No comments:
Post a Comment