GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Jun-2006, 14:37
jdbrine jdbrine is offline
Junior Member
 
Join Date: May 2006
Posts: 56
jdbrine is on a distinguished road

Compile Errors due to Default Parameters


I am receiving compile errors on a function that I am trying to use default parameters on. I do not understand why I am getting these errors. Code and compile errors are listed below:

//stocktank.h
CPP / C++ / C Code:
#include <string>

using namespace std;


class StockTank
{
private:
	int l,w,h,d,r,diam,percap;
	string shape;
	float vol;
	float totcapgal,totcapper;


public:
	StockTankCalculator();
	void SetTankShape(int s);
	void SetTankDataCircle();
	void SetTankDataCircle(int diam, int d);
	void SetTankDataRectangle(int l, int w, int h);
	//void SetTankDataOval();
	float GetTankCapacity();
	float GetTankPercent();
	string GetTankData();

};


//stocktank.cpp
CPP / C++ / C Code:
#include "stocktank.h"
#include <string>
#include <iostream>
#include <cmath>

using namespace std;

double pi=3.14;

StockTank::StockTankCalculator()
{
	shape="circular";
	diam=72;
	d=24;
	r=diam/2;
	GetTankCapacity();
	SetTankDataCircle();




}

void StockTank::SetTankShape(int s)
{


}


void StockTank::SetTankDataCircle()
{
	int diameter;
	int depth;
	shape="circlular";
	diameter=diam;
	depth=d;

	cout.setf(ios::fixed);
	cout.precision(2);
	cout << "The Stock Tank type is " << shape << endl;
	cout << "The tank dimensions are: " << diam <<" \" by " << d << "\"."<<endl; 
	cout << "The Tank capacity (in gallons) of a "<< shape << " tank at 100 % "<<endl;
	cout << "with these dimensions is: "<<totcapgal<<endl<<endl<<endl;

}

void StockTank::SetTankDataRectangle(int l, int w, int h)
{
	int length=0, width=0, height=0;

	cout << "Please enter length of rectangle: "<<;
	cin >> length;
	cout << "Please enter width of rectangle: "<<;
	cin >> width;
	cout << "Please enter height of rectangle: "<<;
	cin >> height;

	l=length;
	w=width;
	h=height;
	shape="rectangular";


}





float StockTank::GetTankCapacity()
{
		vol=pi*(pow(r,2))*d;
		totcapgal=vol/231;


	return totcapgal;
}

float StockTank::GetTankPercent()
{
	cout << "Enter a percentage in whole numbers (ex: 25 = 25%) ";
	cin >> percap;

	totcapper=(totcapgal*percap)*.01;

	cout << "The capacity of the " << shape << " tank at " << percap << "% is " << totcapper << endl << endl;

	return totcapper;

}


//driver.cpp
CPP / C++ / C Code:
#include "stocktank.h"
#include <string>
#include <iostream>

using namespace std;


int main()
{
	int ans;

	cout << "Jerry Brinegar - Program 3"<<endl;
	cout << "CP 278B C++ Programming II"<<endl;
	cout << "6/16/2006"<<endl;

	StockTank Calculator;
	do
	{

	cout << "Stock Tank Calculator"<<endl;
	cout << "Please select from one of the below options"<<endl<<endl;

	cout << "1. Set Tank Shape "<<endl;
	cout << "2. See Tank Information "<<endl;
	cout << "3. Get Tank Capacity Percentage "<<endl;
	cout << "4. Exit Program "<<endl<<endl;

	cout << "Enter your selection 1-4 here: ";
	cin >> ans;
	cout << '\n';

		switch(ans)

		{
		case 1:

			
			cout << "Stock Tank Shape Screen " << endl;
			cout << "Enter a tank type: " << endl;
			cout << "1. Circle" << endl;
			cout << "2. Rectangle" << endl;
			cout << "3. Oval" << endl;
			cout << "4. Return "<< endl;

			int ansshape;
		
			cin >> ansshape;

					
			switch (ansshape)
			{
			case 1:

			Calculator.SetTankShape(ansshape);
			Calculator.SetTankDataCircle();

			case 2:
			Calculator.SetTankShape(ansshape);
			Calculator.SetTankDataRectangle(int l, int w, int h);
//error C2660: 'SetTankDataRectangle' : function does not take 0 parameters

			Calculator.GetTankCapacity();


					
			}

		

			case 2:
		
			Calculator.StockTankCalculator();

			break;

			case 3:
		
			Calculator.GetTankPercent();

 
			break;


			default:

			cout << "You must enter a valid response!" << endl<<endl<<endl;
	
		
		}

	}while(ans!=4);

	return 0;
}

The compile error I am receiving is below, in driver.cpp

Compiling...
driver.cpp
c:\documents and settings\jerry brinegar\desktop\cp278 - visual c++\cp 287b c++\brinegarp3\driver.cpp(60) : error C2144: syntax error : missing ')' before type 'int'
c:\documents and settings\jerry brinegar\desktop\cp278 - visual c++\cp 287b c++\brinegarp3\driver.cpp(60) : error C2660: 'SetTankDataRectangle' : function does not take 0 parameters
c:\documents and settings\jerry brinegar\desktop\cp278 - visual c++\cp 287b c++\brinegarp3\driver.cpp(60) : error C2059: syntax error : ')'
Error executing cl.exe.

driver.obj - 3 error(s), 0 warning(s)


I don't understand why it states that my function SetTankDataRectangle doesn't take 0 parameters. Thank you for any assistance.
  #2  
Old 17-Jun-2006, 14:45
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: Compile Errors due to Default Parameters


The declaration of the function should include the types of the parameters. When calling the function from driver.cpp, you need to actually provide values.
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 4) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile errors earachefl C++ Forum 3 24-Feb-2006 16:49
conditional compile logic cable_guy_67 C++ Forum 15 03-Dec-2005 18:44
Apache2 config issues monev Apache Web Server Forum 2 28-Jun-2004 06:19
Can't view pages from another machine on the Intranet aevans Apache Web Server Forum 9 14-May-2004 02:26
join problem zuzupus MySQL / PHP Forum 0 14-Aug-2003 05:11

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:40.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.