I'm confused as to what the compiler error message I'm getting is refering
to. Can someone take a gander and let me know what I did wrong? The program
is below. When I compile it I get the following error
______________________________
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
d:\temp\complex\temp.cpp:
Error E2333 d:\temp\complex\temp.cpp 73: Class member
'Complex::conjugate(Complex)' declared outside its class
Error E2040 d:\temp\complex\temp.cpp 74: Declaration terminated incorrectly
*** 2 errors in Compile ***
Tool completed with exit code 1
______________________________
Did I screw up with the function which determines the
___________________________________
#include <iostream.h>
#include <math.h>
class Complex {
friend ostream &operator<<( ostream &, Complex & );
public:
Complex( float = 0.0, float = 0.0 );
Complex operator+( Complex & );
Complex operator-( Complex & );
Complex &operator=( Complex & );
bool operator==( Complex & );
private:
Complex conjugate( Complex );
float magnitude( Complex );
float re;
float im;
};
ostream &operator<<( ostream &output, Complex &z )
{
float x = z.re, y = z.im;
if ( y == 0 ) // z = a
output << x;
else if ( x == 0 && y > 0 ) // z = i b
output << "i " << y;
else if ( x == 0 && y < 0 ) // z = - i b
output << "- i " << -y;
else if ( x > 0 && y > 0 ) // z = a + i b
output << x << " + i " << z.im;
else if ( x > 0 && y < 0 ) // z = a - i b
output << x << " - i " << -y;
return output;
}
Complex::Complex( float a, float b )
: re( a ), im( b) { }
Complex Complex::operator+( Complex &z )
{
Complex sum;
sum.re = re + z.re;
sum.im = im + z.im;
return Complex( sum.re, sum.im );
}
Complex Complex::operator-( Complex &z )
{
Complex diff;
diff.re = re - z.re;
diff.im = im - z.im;
return Complex( diff.re, diff.im );
}
Complex& Complex::operator=( Complex &z )
{
re = z.re;
im = z.im;
return *this;
}
bool Complex::operator==( Complex &z )
{
return ( re == z.re && im == z.im );
}
Complex Complex::conjugate( Complex z );
{
return Complex( z.re, -z.im);
}
float Complex::magnitude( Complex z )
{
float x = z.re, y.im;
return sqrt( x*x + y*y );
}
int main()
{
Complex z( 3, 4 );
cout << "z = " << z << endl;
cout << "z* = " << conjugate( z ) << endl:
return 0;
}
___________________________________
Jul 22 '05
65 3992
Jeff Relf wrote: You wrote, ' ISO/IEC Standard 14882, section 5.5: " If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined..." There is no requirement for NaNs to even exist. '
Riiiiiiiiight, as if such a standard would not exist anywhere on the net, so you can't provide a link. Suuuuure. Whatever you say. http://webstore.ansi.org/ansidocstor...C+14882%3A2003
Too lazy to google?
--
Karl Heinz Buchegger kb******@gascad.at
In message <_J*************************@NCPlus.NET>, Jeff Relf
<Me@Privacy.NET> trolled You wrote, ' ISO/IEC Standard 14882, section 5.5: " If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined..." There is no requirement for NaNs to even exist. '
Riiiiiiiiight, as if such a standard would not exist anywhere on the net, so you can't provide a link. Suuuuure. Whatever you say.
Right, whether you like it or not.
In their wisdom, the ISO require you to _pay_ for it. You may not like
it, I might not like it, but they own the copyright, so there's nothing
much we can do about it: http://www.iso.ch/iso/en/CatalogueDe...l?CSNUMBER=381
10&ICS1=35
But you've already proclaimed that you're not interested in standards,
so why would you care?
As for the Subject: line in my headers, People who aren't threading using the References: line are lost causes anyways, I'm not too worried about them. ( Yes, Google's threading is loony, I say )
What a strange way of categorising your fellow humans. What about my Reference:'s line ? What's nonstandard about it ?
It conflicts with your Subject: header.
RFC1036:
2.1.4. Subject
... If the message is submitted in
response to another message (e.g., is a follow-up) the default
subject should begin with the four characters "Re:", and the
"References" line is required...
2.2.5. References
This field lists the Message-ID's of any messages prompting the
submission of this message. It is required for all follow-up
messages, and forbidden when a new subject is raised...
And I _can_ provide a link to that: http://www.faqs.org/rfcs/rfc1036.html As for addressing the individual that I am replying to, that adds a lot of clarity, I say. Sure, it's an open letter, but so what ?
--
Richard Herring
Hi Richard Herring,
Re: Threading.
No matter what any RFC might say,
No matter how f__ked up Google Groups might be,
The Subject: line has nothing to do with threading.
Threading is the sole responsibility of the References line.
That's not my opinion ... It's just the harsh reality.
Focusing too hard on fanciful standards
makes one blind to such realities.
Likewise,
it doesn't matter what that 300 dollar book of yours says,
NaN is the only appropriate response to a divide by zero.
And hanging is Never Ever the appropriate response.
If you had any paying clients, you'd already know that.
You can argue till the cows come home,
I won't change my mind.
And, Unless and until you show me an authoritative web link,
I'll continue to believe that NaN is the standard response.
Jeff Relf wrote: [redacted]
PLONK!
(and it takes a hell of a lot for me to say that publicly)
Hi red floyd,
You commented, " PLOINK ! Oink. Oink. "
Comp.Lang.C++ blows.
I'm very proud of having absolutely no one ploinked.
Even back when I did ploink,
I still scored Absolutely All replies high.
I read all replies, no matter who they are.
Besides, Announcing Ploinks is just plain piggish.
Oink. Oink.
Hi Bill Seurer,
You commented,
" Some hardware
will throw an exception if you divide by zero
irregardless of any way you compiled your code. "
Microsoft Windows code, for PC's,
returns a NaN by default, when compiling for release.
I'm not targeting other platforms.
Cross-platform code is a very bad joke.
If you think your code will work, and work _ Well _ ,
no matter if it's running on a Mac G5 with a 40 inch TFT
or a cell phone ...
Then I have a bridge to sell you in Manhattan.
"Jeff Relf" <Me@Privacy.NET> wrote Hi Bill Seurer,
You commented, " Some hardware will throw an exception if you divide by zero irregardless of any way you compiled your code. "
Microsoft Windows code, for PC's, returns a NaN by default, when compiling for release.
I'm not targeting other platforms.
Cross-platform code is a very bad joke. If you think your code will work, and work _ Well _ , no matter if it's running on a Mac G5 with a 40 inch TFT or a cell phone ...
Then I have a bridge to sell you in Manhattan.
Are you planning on growing up any time soon? Enough with the infantile antics
already.
Claudio Puviani
"Claudio Puviani" <pu*****@hotmail.com> wrote... "Jeff Relf" <Me@Privacy.NET> wrote [...] Are you planning on growing up any time soon? Enough with the infantile
antics already.
Stop feeding this troll, he'll go away by himself.
Claudio Puviani wrote: Jeff Relf wrote:
Cross-platform code is a very bad joke. If you think your code will work, and work _ Well _ , no matter if it's running on a Mac G5 with a 40 inch TFT or a cell phone ...
Then I have a bridge to sell you in Manhattan.
Are you planning on growing up any time soon? Enough with the infantile
antics already.
I wrote a program for PC and Linux, and tossed it on the 'net.
Googling for it later revealed a few people run it on the Sharp Zaurus PDA.
(It ain't in C++, though! ;-)
Most of the time, portability is for canoos. (Knowing how to be portable is
a sign of professionalism.) But after the first two platforms, the rest are
easier.
--
Phlip http://industrialxp.org/community/bi...UserInterfaces
In message <_J*************************@NCPlus.NET>, Jeff Relf
<Me@Privacy.NET> writes Hi Richard Herring,
Re: Threading.
No matter what any RFC might say,
Your attitude to standards is already blindingly clear.
No matter how f__ked up Google Groups might be,
Who mentioned Google?
The Subject: line has nothing to do with threading. Threading is the sole responsibility of the References line.
That's not my opinion ... It's just the harsh reality.
Focusing too hard on fanciful standards makes one blind to such realities.
Likewise, it doesn't matter what that 300 dollar book of yours says,
Wrong as usual. $18 online.
NaN is the only appropriate response to a divide by zero.
You've never heard of exceptions?
And hanging is Never Ever the appropriate response.
If you had any paying clients, you'd already know that.
No bite. My customer list is confidential. You can argue till the cows come home, I won't change my mind.
And, Unless and until you show me an authoritative web link, I'll continue to believe that NaN is the standard response.
Believe what you like.
--
Richard Herring
Jeff Relf wrote: Oink. Oink.
Please let the door hit you on your way out.
Jeff Relf <Me@Privacy.NET> wrote: NaN is the only appropriate response to a divide by zero. And hanging is Never Ever the appropriate response.
*In your opinion*
If you had any paying clients, you'd already know that.
And in your clients opinion too, perhaps. Other paying clients
have different opinions. On IA32 platforms, AFAIK, it is slower
to check for zero and give a NaN than to go ahead and do the division.
For clients whose income depends on the speed of their application,
and are clever enough to not go around dividing by zero,
your philosophy would be a big turn-off.
You can argue till the cows come home, I won't change my mind.
How old are you again?
And, Unless and until you show me an authoritative web link, I'll continue to believe that NaN is the standard response.
If you have so many "paying clients" , why can't you afford
to read the C++ Standard ?
Hi Phlip,
You wrote,
" I wrote a program for PC and Linux,
and tossed it on the 'net.
Googling for it later revealed
a few people run it on the Sharp Zaurus PDA.
( It ain't in C++, though ! ;-) "
What language ? C ? What does it do ?
What with cheap flash memory and all,
Today's hand-helds are
far better than yesterday's big iron.
Linux on a hand-held is a real possibility these days ...
even for penniless people like me.
But I don't retract anything I said before,
A program that runs well on a cell phone
will not run _ Well _ on a dual CPU Mac G5
with a 40 inch LCD.
Customization is a fact of life.
Cross platform languages like C# are jokes, I say.
P.S. I had to repost this because
the Newsfroups: line apparently doesn't allow spaces.
Hi Old Wolf,
You're posting via Google ? Why the anonymity ?
Google is the mark of a troll where I come from.
You asked me:
' If you have so many " paying clients ",
why can't you afford to read the C++ Standard ? "
Although I have a high hourly rate,
I work _ Very _ few hours per year. Very few.
I'm all play and no work ...
makes jack less of a dull boy.
As for the speed of NaN's vs. Hanging ...
Hanging is slower.
By the way,
For a group of guys that proclaims a love of standards,
I'm amazed that no one here can point to
an authoritative link about
the default action when dividing by zero.
Hi Bill Seurer,
Wow, comp.lang.c++ is full of nymshifting trolls ?
Who'd a thunk it ?
Bill Seurer at work : IBM.COM,
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
... a.k.a. Red Floyd at home: de4c3138, Prodigy.COM,
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
So your ploink was just an insult then ...
and nothing more ?
Jeff Relf <Me@Privacy.NET> wrote: Hi Old Wolf,
You're posting via Google ? Why the anonymity ?
Your address is "Me@Privacy.NET" and you call me the anonymous one?
Google is the mark of a troll where I come from.
And where is that? (Due to your anonymous posting, I can't tell)
As for the speed of NaN's vs. Hanging ...
Hanging is slower.
Hanging is not slow if it never happens.
By the way, For a group of guys that proclaims a love of standards, I'm amazed that no one here can point to an authoritative link about the default action when dividing by zero.
I'm amazed at how lazy you are. You seem to think that because nobody
can be bothered doing research on your behalf, you are automatically
right. It certainly takes less effort to search for "C++ programming"
on the ISO website ( www.iso.org), than it takes you to write these posts.
I shall now take the advice of CBFalconer, and stop feeding you.. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: blueblueblue2005 |
last post by:
Hi, I am reading the const function definition part in Deitel book, it
says :
Defining as const a member function that calls a non-const member
function of the class on the same instance of the...
|
by: Carmine Cairo |
last post by:
Hi,
I'm working on a project and today I've note a little problem during the
compile fase.
Here a little piece of code:
// 1st version
welldone = 0;
size = p->getSize();
backbone = new...
|
by: Chris LaJoie |
last post by:
Our company has been developing a program in C# for some time now, and we
haven't had any problems with it, but just last night something cropped up
that has me, and everyone else, stumped.
I...
|
by: BillyM |
last post by:
I have an MDI parent form called "MDIParentView" that inherits from the UIP
Application Block's WinFormView. The method to start a task using this MDI
form is defined as follows:
public static...
|
by: Thomas Connolly |
last post by:
I have 2 pages referencing the same codebehind file in my
project. Originally the pages referenced separate code
behind files. Once I changed the reference to the same
file, everything worked...
|
by: ThunderMusic |
last post by:
Hi,
I'd like to create a compile time error in my class... maybe there's a way
already built in in the framework so I can achieve what I want... I have 2
constructors in my class. One of them...
|
by: Wilson |
last post by:
Hi, while writing a simplified version of a program i created the
following class, however when i went to compile and run the program
there was an error saying
"multiple types in one...
|
by: PekinSOFT |
last post by:
Hey all,
I'm working through the book "GUI Programming with Qt3" and have
worked my way through Chapter 4, creating a small spreadsheet
application. I'm finally to a point where I can compile...
|
by: Luna Moon |
last post by:
Hi all,
I just couldn't get myself clear about the usage of "const" in front
of and/or behind variables, pointers, classes, objects and
functions...
It's too confusing... any good clear...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |