I don't get how to rid my program of this error:
Code:
c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(88) : error C2511: 'void Fin::initialize(const Fin &)' : overloaded member function not found in 'Fin'
c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(61) : see declaration of 'Fin'
I appreciate it!
Here's my code:
Code:
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
// This is a skeleton hw13.h file. You must complete it.
// You are not allowed to modify the parts of the class
// definitions provided for you with the exception that you
// have to provide public member functions to allow the
// access that you need.
const int maxFinHeight = 100;
const int maxFinWidth = 100;
class Steampipe
{
private:
int height,width;
double steamTemp;
public:
Steampipe (int H = 0, int W = 0, double sT = 0.0)
{
height = H;
width = W;
steamTemp = sT;
}
int getheight()const{return height;}
int getwidth()const{return width;}
double getsteamTemp()const{return steamTemp;}
void setheight(int h = 0){height = h;}
void setwidth(int w = 0){width = w;}
void setsteamtemp(double temp = 0){steamTemp = temp;}
// Access function definitions
};
class GridPt
{
private:
double temperature;
char symbol;
public:
GridPt(double t = 0.0, char s = '?')
{
temperature = t;
symbol = s;
}
double gettemperature()const{return temperature;}
char getsymbol()const{return symbol;}
void setTemperature(double temp = 0){temperature = temp;}
void setSymbol(char symb = '?'){symbol = symb;}
// Access function definitions
};
class Fin
{ //line 61
private:
int width, height; //width and height of fin
int pipeLocationX, pipeLocationY; //grid location of lower left corner of steampipe
double boundaryTemp; //temperature of fin surroundings
Steampipe Pipe; //steampipe object - COMPOSITION
GridPt GridArray[maxFinHeight][maxFinWidth]; // array of GridPts - COMPOSITION
public:
void compute(double delta, int maxIterations);
double getboundaryTemp() const {return boundaryTemp;}
int getwidth()const{return width;}
int getheight()const{return height;}
int getpipeX()const{return pipeLocationX;}
int getpipeY()const{return pipeLocationY;}
void initialize(); // YOU MUST DEFINE
void setFwidth(int w = 0){width = w;}
void setFheight(int h = 0){height = h;}
void setPx(int x = 0){pipeLocationX = x;}
void setPy(int y = 0){pipeLocationY = y;}
void setFtemp(double temp = 0){boundaryTemp = temp;}
friend istream& operator>>(istream& , Fin&); // YOU MUST DEFINE
friend ostream& operator<<(ostream& , const Fin& ); // YOU MUST DEFINE
};
void Fin::initialize(const Fin& F)
{ //line 88
//------SETS ALL TO AVERAGE---------------------
for(int i = height - 1; i >= 0; i--)
{
for(int j = 0; j <= width - 1; j++)
{
F.GridArray[i][j].setTemperature((boundaryTemp + F.Pipe.steamTemp)/2);
char symb = 'X';
F.GridArray[i][j].setSymbol(symb);
}
}
//-----------------------------------------------
//------SETS BOUNDARY OF FIN TEMP AND CHAR-------
for(int i = height - 1, int j = 0; j < width; j++)
{
F.GridArray[i][j].setTemperature(boundaryTemp);
char symb = 'C';
F.GridArray[i][j].setSymbol(symb);
}
for(int i = 0, int j = 0; j < width; j++)
{
F.GridArray[i][j].setTemperature(boundaryTemp);
char symb = 'C';
F.GridArray[i][j].setSymbol(symb);
}
for(int j = 0, int i = 0; i < height; i++)
{
F.GridArray[i][j].setTemperature(boundaryTemp);
char symb = 'C';
F.GridArray[i][j].setSymbol(symb);
}
for(int j = width - 1, int i = 0; i < height; i++)
{
F.GridArray[i][j].setTemperature(boundaryTemp);
char symb = 'C';
F.GridArray[i][j].setSymbol(symb);
}
//-------------------------------------------------
//------SETS PIPE TEMP AND CHAR--------------------
for(int i = height - 1 - pipeLocationY; i > height - 1 - pipeLocationY - F.Pipe.height; i--)
{
for(int j = pipeLocationX; j < F.Pipe.width + pipeLocationX; j++)
{
F.GridArray[i][j].setTemperature(F.Pipe.steamTemp);
char symb = 'H';
F.GridArray[i][j].setSymbol(symb);
}
}
}
istream& operator>>(istream& in, Fin& F)
{
char trash;
int fHeight, fWidth, pHeight, pWidth, pX, pY;
double sTemp, fTemp;
cout << "Enter the height of the fin (integer) >>> ";
in >> fHeight;
F.setFheight(fHeight);
cout << "Enter the width of the fin (integer) >>> ";
in >> fWidth;
F.setFwidth(fWidth);
cout << "Enter the height of the steampipe (integer) >>> ";
in >> pHeight;
F.Pipe.setheight(pHeight);
cout << "Enter the width of the steampipe (integer) >>> ";
in >> pWidth;
F.Pipe.setwidth(pWidth);
cout << "Enter integer coordinates of lower left corner of the steampipe (X,Y) >>> ";
in >> pX >> trash >> pY;
F.setPx(pX);
F.setPy(pY);
cout << "Enter the steam temperature (floating point) >>> ";
in >> sTemp;
F.Pipe.setsteamtemp(sTemp);
cout << "Enter the temperature around the fin (floating point) >>> ";
in >> fTemp;
F.setFtemp(fTemp);
}
ostream& operator<<(ostream& out, const Fin& F)
{
cout << "The width of the fin is " << F.getwidth() << endl;
cout << "The height of the fin is " << F.getheight() << endl;
cout << "The outside temperature is " << F.getboundaryTemp() << endl;
cout << "The lower left corner of the steam pipe is at (" << F.getpipeX() << ", " << F.getpipeY() << ")" << endl;
cout << "The steam pipe width is " << F.Pipe.getwidth() << endl;
cout << "The steam pipe height is " << F.Pipe.getheight() << endl;
cout << "The temperature of the steam is " << F.Pipe.getsteamTemp() << endl << endl;
}