Sunday, July 12, 2009

Cant figure out whats wrong C++?

//Class declaration for the rectangle class





class house


{


public:


//default constructor


house():





house(double l, double w, double h, double R_wall, double R_ceiling, double in_temp, double out_temp);





//accesor funtions


double get_length() const;


double get_width() const;


double get_height() const;


double get_R_walls() const;


double get_R_ceilings() const;


double get_in_temp() const;


double get_out_temp() const;





//function for input and output.





double input(istream%26amp; in);


double output(ostream%26amp; out) const;





//additional member function prototypes.


void set_value(double l, double w, double h, double R_wall, double R_ceiling, double in_temp, double out_temp);


double area() const;





private:


//declaration of data members;


double length, width, height, R_walls, R_ceilings, in_temp, out_temp;


};


#endif


























#include %26lt;iostream%26gt;


using namespace std;


using :: istream;


using :: ostream;





house:house(double l, double w, double h, double R_wall, double R_ceiling, double in_temp, double out_temp);


length(l), width(w), height(h), R_walls(R_wall), R_ceilings(R_ceiling), in_temp(in_temp), out_temp(out_temp);


{


}





void house::set_value(double l, double w, double h, double R_wall, double R_ceiling, double in_temp, double out_temp)


{


//set the value of the calling object.


length = l;


width = w;


height = h;


R_walls = R_wall ;


R_ceilings = R_ceiling;


in_temp = in_temp;


out_temp = out_temp;


return;


}

Cant figure out whats wrong C++?
1.)


When you declare house::house(), you should write "house();" not "house:". Using a colon instead of a semicolon makes the compiler expect to see an initialization list.





2.)


When you define house::house(), you should write "house::house", not "house:house", because "house::house" is the fully-qualified name of the function, whereas "house:house" is simply an illegal construct.





3.)


When you give an initialization list for house::house, you should not terminate the initialization list in a semicolon. The initialization list is terminated by the open brace.





4.)


You appear to be missing the definitions of a number of other functions.





5.)


You should define a copy constructor "house::house(const house%26amp;)", and then you can simply use the default assignment operator instead of set_value.


No comments:

Post a Comment