One error left! Plz help, me=noob

This is a discussion on One error left! Plz help, me=noob within the C++ Programming forums, part of the General Programming Boards category; 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 ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    15

    One error left! Plz help, me=noob

    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;
    }

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    85
    In your initialise function class definition you don't hav the argument Fin.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    I'm not sure I understand. I pass Fin& F to initialize, and use F.GridArray... and such. What exactly do I have to change?

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    85
    void initialize(); // YOU MUST DEFINE
    void Fin::initialize(const Fin& F)

    Your prototype and implementation do not match

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    Hmm, when I change void initialize() in the Fin class to void initialize(const Fin&) it seems to take care of the error, but then creates a few more....

    Code:
    Compiling...
    HW14.cpp
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(94) : error C2248: 'Steampipe::steamTemp' : cannot access private member declared in class 'Steampipe'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(19) : see declaration of 'Steampipe::steamTemp'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(16) : see declaration of 'Steampipe'
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(94) : error C2662: 'GridPt::setTemperature' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(96) : error C2662: 'GridPt::setSymbol' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(102) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(102) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(104) : error C2662: 'GridPt::setTemperature' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(106) : error C2662: 'GridPt::setSymbol' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(108) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(108) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(110) : error C2662: 'GridPt::setTemperature' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(112) : error C2662: 'GridPt::setSymbol' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(114) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(114) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(116) : error C2662: 'GridPt::setTemperature' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(118) : error C2662: 'GridPt::setSymbol' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(120) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(120) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(122) : error C2662: 'GridPt::setTemperature' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(124) : error C2662: 'GridPt::setSymbol' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(129) : error C2248: 'Steampipe::height' : cannot access private member declared in class 'Steampipe'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(18) : see declaration of 'Steampipe::height'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(16) : see declaration of 'Steampipe'
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(131) : error C2248: 'Steampipe::width' : cannot access private member declared in class 'Steampipe'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(18) : see declaration of 'Steampipe::width'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(16) : see declaration of 'Steampipe'
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(133) : error C2248: 'Steampipe::steamTemp' : cannot access private member declared in class 'Steampipe'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(19) : see declaration of 'Steampipe::steamTemp'
            c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(16) : see declaration of 'Steampipe'
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(133) : error C2662: 'GridPt::setTemperature' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.h(135) : error C2662: 'GridPt::setSymbol' : cannot convert 'this' pointer from 'const GridPt' to 'GridPt &'
            Conversion loses qualifiers
    c:\Documents and Settings\Kevin\My Documents\Visual Studio Projects\HW14\HW14.cpp(7) : error C2660: 'Fin::initialize' : function does not take 0 arguments
    I don't get it.....

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    I dont think anything is supposed to be passed to initialize actually. Does anyone know how I can access the data members without passing Fin in the initialize function?

  7. #7
    Registered User
    Join Date
    Oct 2005
    Posts
    15
    Hold on, I may have it.

  8. #8
    Registered User
    Join Date
    Nov 2005
    Posts
    85
    Fin f;
    f.Intialise();

    And remove all references to the F in the implementation

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 10:19 PM
  2. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  3. Anyone plz help me
    By Rose_Flowers in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-17-2003, 01:01 PM
  4. plz help me fix this problem
    By Joe100 in forum C++ Programming
    Replies: 8
    Last Post: 07-13-2003, 02:25 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21