BLIND-DEV Archives

Development of Adaptive Hardware & Software for the Blind/VI

BLIND-DEV@LISTSERV.ICORS.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"John A. Byerly" <[log in to unmask]>
Reply To:
BLIND-DEV: Development of Adaptive Hardware & Software for the Blind/VI" <[log in to unmask]>
Date:
Fri, 2 Apr 2004 10:39:51 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (489 lines)
Hi,

Just at a quick glance, you might try changing the names of your member data
(length, radius, etc.)  These names may be colliding with the parameter
names in your constructor (which are also length, radius, etc.).  One coding
standard to consider is to use m_ (lower case m followed by an underscore
character) as a prefix to each member data name.  This will differentiate
them from the parameter names in your functions.

Hope this helps!

JAB
--------------------------------------------------------
John A. Byerly
Engineered Software Solutions, Ltd.
http://www.ess-quality.com
(724) 598-7990 (voice)
(724) 598-7992 (fax)


> -----Original Message-----
> From: BLIND-DEV: Development of Adaptive Hardware & Software for the
> Blind/VI [mailto:[log in to unmask]]On Behalf Of Marvin
> Hunkin
> Sent: Thursday, April 01, 2004 9:30 PM
> To: [log in to unmask]
> Subject: C++ Errors
>
>
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_000A_01C418AE.3D93A980
> Content-Type: text/plain;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> Hi.
> i will post the code and the error message below.
> still confused about constructors.
> please help me out.
> i am getting confused, frustrated, and really fed up.
> why it is not working.
> Am i just a dummy?
> please give me exact code examples.
> how to fix this problem.
> Cheers Marvin.
>
>
> /*
> * Program: C++ Session 21 Exercise
> * File Name: Paddock.cpp
> *Description: Session 21 Exerciseto design a program for a farmer to =
> water a area of his paddock
> * Creator: Marvin Hunkin
> *Date Created: Friday March 19 2004 3:35 pm
>  * Version: 1.00
>  */
>
>
>
> //iostream is needed for input and output
>
>
> #include <iostream.h>
> #include <conio.h>
> #include <math.h>
>
> using namespace std;
>
>
>
> class Tanker
> {
>         public:
>  float radius;
>  float length;
>  float fertaliserlevel;
>  float fertaliser;
>  float water;
>  float size;
>  float pi;
>  float width;
>  float hectre;
> float area;
>
>
> Tanker(float radius, float length,float fertaliserlevel);
>
> void Title();
>  float TotalVolume(float pi,  float radius, float length);
>  float VolumeOccupiedSpace(float depth, float length);
>  int Convert();
> void PromptFertaliser();
> void PromptHectre();
>   float CalculateArea(float fertaliser, float water);
>  void Result();
>  void PromptLiquid();
> };  //close Tanker class
>
>
>
>               int main ()
> {
>
>
>       Tanker myTanker(r,l,f);
>
>
>  myTanker.fertaliser=3D0.75;
>  myTanker.water=3D0.25;
>  myTanker.pi=3D3.1415;
>  myTanker.width=3D10;
>  myTanker.hectre=3D10000;
>  myTanker.Title();
>         myTanker.PromptFertaliser();
>   myTanker.PromptHectre();
>        myTanker.Result();
>    myTanker.PromptLiquid();
>                                  getch ();
>                 return 0;
> } //close main function
>
>
>  void Tanker::Title()
> {
> cout <<"\nWelcome To Marvins Paddock ";
> cout << "\nThis program asks the user to enter a number for the amount =
> of liquid to be entered into the tanker. ";
> cout << "\nFrom the keyboard. ";
> cout << "\nAnother pprompt appears on screen, asking the user to enter a =
> number , for the amount of area they wish to use for the paddock. ";
> cout << "\nFrom the keyboard. ";
> cout << "\nAnother prompt  appears on screen, asking the user to enter =
> the amount of liquid which they want to use for the tanker. " ;
> cout << "\nFrom the keyboard. ";
> cout << "\nthen the total fertaliser, total water, total volume and =
> total area used for the paddock appears on screen. ";
> } //close title function
>
>
>  float Tanker::TotalVolume(float Pi,  float Radius, float Length  )
> {
> float answer;
>   answer =3D Pi * Radius * Radius * Length;
>   return answer;
> } //close total Volume function
>
>  float Tanker::VolumeOccupiedSpace(float Depth, float Length)
> {
> float depth;
>     float depthDivideRadius =3D ((radius - depth) / radius);
>                   float theta =3D 2*acos(depthDivideRadius);
>                   float surfaceArea =3D (radius * radius) * (theta -
> sin(theta))/2;
>                   float segmentVolume =3D surfaceArea * length;
>                   return segmentVolume;
>                                         } // close  volumeOccupiedSpace =
> function
>
>
>  int Tanker::Convert()
> {
>  int answer=3D0;
>  int hectre=3D10000;
>  int millimetres=3D1000 ;
>   answer=3Dmillimetres / 1000;
>   answer=3Dhectre / 10000;
>          return answer;
> } //close Convert function
>
>
> void Tanker::PromptFertaliser()
> {
>  float EnterTank=3D0.0;
>
>  cout << "Type a number, then press enter: "  << endl;
>          cin >> EnterTank;
>
> } //close promptFertaliser function
>
>
> void Tanker::PromptHectre()
> {
> float EnterArea=3D0.0;
>  cout << " Type a number, then press enter: " << endl;
>   cin >> EnterArea;
>               } // close promptHectre function
>
>
>  float Tanker::CalculateArea(float Fertaliser, float Water)
> {
>  float answer;
>     answer =3Dsize * fertaliser * water;
>    return answer;
> } //close calculateArea function
>
>
>
> void Tanker::Result()
> {
>  cout << "Total Fertaliser Used: " << fertaliser * 0.75 << " Litres " << =
> endl;
>  cout << "Total Water Used: " << water * 0.25 << " Litres " << endl;
>  cout << "Total Volume Used: " << pi * radius * radius * length << " =
> Litres " << endl;
>  cout << "Total Area Used: " << area *  width * length * hectre   << =
> "Hectres " << endl;
>                      } //close result function
>
>
> void Tanker::PromptLiquid()
> {
> cout << "Enter  a number, then press enter: " << endl;
> } //close PromptLiquid function
>
>
> Tanker::Tanker(float r, float l, float f)
> {
>    radius =3D r;
>  length =3D l;
>  fertaliserlevel =3D f;
> } //close tanker constructor
>
> [C++ Error] Paddock.cpp(57): E2084 Parameter names are used only with a =
> function body
>
> [C++ Error] Paddock.cpp(59): E2139 Declaration missing ;
>
> [C++ Error] Paddock.cpp(60): E2451 Undefined symbol 'myTanker'
>
>
>
> ps: it is the constructor, which i have diagnosed, but don't know how to =
> fix it. tried several things, but not liking it.
> giving me a migrain.
>
>
>
>
>
>
>
> ------=_NextPart_000_000A_01C418AE.3D93A980
> Content-Type: text/html;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=3DContent-Type content=3D"text/html; =
> charset=3Diso-8859-1">
> <META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT face=3DArial size=3D2>Hi.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>i will post the code and the error =
> message=20
> below.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>still confused about =
> constructors.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>please help me out.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>i am getting confused, frustrated, and =
> really fed=20
> up.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>why it is not working.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>Am i just a dummy?</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>please give me exact code =
> examples.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>how to fix this problem.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>Cheers Marvin.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2>/*<BR>* Program: C++ Session 21 =
> Exercise<BR>* File=20
> Name: Paddock.cpp<BR>*Description: Session 21 Exerciseto design a =
> program for a=20
> farmer to water a area of his paddock<BR>* Creator: Marvin =
> Hunkin<BR>*Date=20
> Created: Friday March 19 2004 3:35 pm<BR>&nbsp;* Version:=20
> 1.00<BR>&nbsp;*/</FONT></DIV>
> <DIV>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2>//iostream is needed for input and=20
> output</FONT></DIV>
> <DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
> <DIV><BR>#include &lt;iostream.h&gt;<BR>#include =
> &lt;conio.h&gt;<BR>#include=20
> &lt;math.h&gt;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>using namespace std;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>class Tanker<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> public:<BR>&nbsp;float radius;<BR>&nbsp;float length;<BR>&nbsp;float=20
> fertaliserlevel;<BR>&nbsp;float fertaliser;<BR>&nbsp;float =
> water;<BR>&nbsp;float=20
> size;<BR>&nbsp;float pi;<BR>&nbsp;float width;<BR>&nbsp;float =
> hectre;<BR>float=20
> area;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>Tanker(float radius, float length,float fertaliserlevel);</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>void Title();<BR>&nbsp;float TotalVolume(float pi,&nbsp; float =
> radius,=20
> float length);<BR>&nbsp;float VolumeOccupiedSpace(float depth, float=20
> length);<BR>&nbsp;int Convert();<BR>void PromptFertaliser();<BR>void=20
> PromptHectre();<BR>&nbsp; float CalculateArea(float fertaliser, float=20
> water);<BR>&nbsp;void Result();<BR>&nbsp;void =
> PromptLiquid();<BR>};&nbsp;=20
> //close Tanker class</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
> bsp;&nbsp;=20
> int main ()<BR>{</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tanker myTanker(r,l,f);</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>&nbsp;myTanker.fertaliser=3D0.75;<BR>&nbsp;myTanker.water=3D0.25=
> ;<BR>&nbsp;myTanker.pi=3D3.1415;<BR>&nbsp;myTanker.width=3D10;<BR>&nbsp;m=
> yTanker.hectre=3D10000;<BR>&nbsp;myTanker.Title();<BR>&nbsp;&nbsp;&nbsp;&=
> nbsp;=20
> &nbsp;&nbsp; myTanker.PromptFertaliser();<BR>&nbsp;=20
> myTanker.PromptHectre();<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=20
> myTanker.Result();<BR>&nbsp;&nbsp;=20
> myTanker.PromptLiquid();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> getch=20
> ();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
> &nbsp;&nbsp;&nbsp;&nbsp;=20
> return 0;<BR>} //close main function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>&nbsp;void Tanker::Title()<BR>{<BR>cout &lt;&lt;"\nWelcome To =
> Marvins=20
> Paddock ";<BR>cout &lt;&lt; "\nThis program asks the user to enter a =
> number for=20
> the amount of liquid to be entered into the tanker. ";<BR>cout &lt;&lt; =
> "\nFrom=20
> the keyboard. ";<BR>cout &lt;&lt; "\nAnother pprompt appears on screen, =
> asking=20
> the user to enter a number , for the amount of area they wish to use for =
> the=20
> paddock. ";<BR>cout &lt;&lt; "\nFrom the keyboard. ";<BR>cout &lt;&lt;=20
> "\nAnother prompt&nbsp; appears on screen, asking the user to enter the =
> amount=20
> of liquid which they want to use for the tanker. " ;<BR>cout &lt;&lt; =
> "\nFrom=20
> the keyboard. ";<BR>cout &lt;&lt; "\nthen the total fertaliser, total =
> water,=20
> total volume and total area used for the paddock appears on screen. =
> ";<BR>}=20
> //close title function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>&nbsp;float Tanker::TotalVolume(float Pi,&nbsp; float Radius, =
> float=20
> Length&nbsp; )<BR>{<BR>float answer;<BR>&nbsp; answer =3D Pi * Radius * =
> Radius *=20
> Length;<BR>&nbsp; return answer;<BR>} //close total Volume =
> function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;float Tanker::VolumeOccupiedSpace(float Depth, float=20
> Length)<BR>{<BR>float depth;<BR>&nbsp;&nbsp;&nbsp; float =
> depthDivideRadius =3D=20
> ((radius - depth) /=20
> radius);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> float theta =3D=20
> 2*acos(depthDivideRadius);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> float surfaceArea =3D (radius * radius) * (theta=20
> -<BR>sin(theta))/2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> float segmentVolume =3D surfaceArea *=20
> length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> return=20
> segmentVolume;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
> nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
> bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
> sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> } // close&nbsp; volumeOccupiedSpace function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>&nbsp;int Tanker::Convert()<BR>{<BR>&nbsp;int =
> answer=3D0;<BR>&nbsp;int=20
> hectre=3D10000;<BR>&nbsp;int millimetres=3D1000 ;<BR>&nbsp; =
> answer=3Dmillimetres /=20
> 1000;<BR>&nbsp; answer=3Dhectre /=20
> 10000;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
> answer;<BR>}=20
> //close Convert function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>void Tanker::PromptFertaliser()<BR>{<BR>&nbsp;float=20
> EnterTank=3D0.0;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;cout &lt;&lt; "Type a number, then press enter: "&nbsp; =
> &lt;&lt;=20
> endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;cin &gt;&gt;=20
> EnterTank;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>} //close promptFertaliser function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>void Tanker::PromptHectre()<BR>{<BR>float =
> EnterArea=3D0.0;<BR>&nbsp;cout=20
> &lt;&lt; " Type a number, then press enter: " &lt;&lt; endl;<BR>&nbsp; =
> cin=20
> &gt;&gt;=20
> EnterArea;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
> ;&nbsp;&nbsp;&nbsp;=20
> } // close promptHectre function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>&nbsp;float Tanker::CalculateArea(float Fertaliser, float=20
> Water)<BR>{<BR>&nbsp;float answer;<BR>&nbsp;&nbsp;&nbsp; answer =3Dsize =
> *=20
> fertaliser * water;<BR>&nbsp;&nbsp; return answer;<BR>} //close =
> calculateArea=20
> function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>void Tanker::Result()<BR>{<BR>&nbsp;cout &lt;&lt; "Total Fertaliser =
> Used: "=20
> &lt;&lt; fertaliser * 0.75 &lt;&lt; " Litres " &lt;&lt; =
> endl;<BR>&nbsp;cout=20
> &lt;&lt; "Total Water Used: " &lt;&lt; water * 0.25 &lt;&lt; " Litres " =
> &lt;&lt;=20
> endl;<BR>&nbsp;cout &lt;&lt; "Total Volume Used: " &lt;&lt; pi * radius =
> * radius=20
> * length &lt;&lt; " Litres " &lt;&lt; endl;<BR>&nbsp;cout &lt;&lt; =
> "Total Area=20
> Used: " &lt;&lt; area *&nbsp; width * length * hectre&nbsp;&nbsp; =
> &lt;&lt;=20
> "Hectres " &lt;&lt;=20
> endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
> p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
> } //close result function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>void Tanker::PromptLiquid()<BR>{<BR>cout &lt;&lt; "Enter&nbsp; =
> a=20
> number, then press enter: " &lt;&lt; endl;<BR>} //close PromptLiquid=20
> function</DIV>
> <DIV>&nbsp;</DIV>
> <DIV><BR>Tanker::Tanker(float r, float l, float f)<BR>{<BR>&nbsp; =
> &nbsp;radius =3D=20
> r;<BR>&nbsp;length =3D l;<BR>&nbsp;fertaliserlevel =3D f;<BR>} //close =
> tanker=20
> constructor</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>
> <P class=3DMsoPlainText style=3D"MARGIN: 0cm 0cm 0pt"><SPAN=20
> style=3D"mso-fareast-font-family: 'MS Mincho'"><FONT face=3D"Courier =
> New">[C++=20
> Error] Paddock.cpp(57): E2084 Parameter names are used only with a =
> function=20
> body<?xml:namespace prefix =3D o ns =3D =
> "urn:schemas-microsoft-com:office:office"=20
> /><o:p></o:p></FONT></SPAN></P>
> <P class=3DMsoPlainText style=3D"MARGIN: 0cm 0cm 0pt"><SPAN=20
> style=3D"mso-fareast-font-family: 'MS Mincho'"><FONT face=3D"Courier =
> New">[C++=20
> Error] Paddock.cpp(59): E2139 Declaration missing =
> ;<o:p></o:p></FONT></SPAN></P>
> <P class=3DMsoPlainText style=3D"MARGIN: 0cm 0cm 0pt"><SPAN=20
> style=3D"mso-fareast-font-family: 'MS Mincho'"><FONT face=3D"Courier =
> New">[C++=20
> Error] Paddock.cpp(60): E2451 Undefined symbol=20
> 'myTanker'<o:p></o:p></FONT></SPAN></P></DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>ps: it is the constructor, which i have diagnosed, but don't know =
> how to=20
> fix it. tried several things, but not liking it.<BR>giving me a=20
> migrain.<BR></DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV>&nbsp;</DIV>
> <DIV></FONT>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>
>
> ------=_NextPart_000_000A_01C418AE.3D93A980--
>
>
>

ATOM RSS1 RSS2