Well, you could post the code for starters.
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
Try moving line 9 to line 6.
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
It shouldn't have.
Problem #1) Never define a variable in a header file. The statement float PI = 3.146; shouldonly be made in a source file. If you add the header to 4 source files, you will have 4 definitions of PI causing lots of errors.
Problem #2) The extern statement goes in the header file so other sources that include the .h file know that PI will be defined in another source.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Try this:
cout << "PI Is Equal To: " << fixed << PI << endl;
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
well this is how my class thought me to do it, its called external variables they said ,
it is just like defining constants in a header file and the extern keyword tells the compiler that that variable is external and not to confuse with other "PI" variables from other namespaces ect...
I believe you misunderstood your class. And if not, you need an instructor that knows the language because your understanding is not correct.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944