| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
need help, this is my 2nd prog. I'm trying to create a class and use it to find the area and length of boundary. I got no errors but 3 warnings and the calculation came out wrong...please help
#include <cstdlib> #include <iostream> using namespace std; //==================class begins========= class plot { private: int length; int widht; public: int area(int, int); int boundary(int, int); }; //======================ends class======= //==========================plot constructor initiate=================== plot::area(int x, int y) {return x*y;} plot::boundary(int x, int y) {return 2*(x+y);} //=========plot constructor end============ //========main================= int main() { plot z; int x=7; int y=9; cout<<"Area is: "<<z.area<<endl; cout<<"Length of boundary is: "<<z.boundary<<endl; cout<<"\n"; return 0; } |
|
#2
|
||||||||||||||
|
||||||||||||||
|
Changing this:
cpp Code:
into: cpp Code:
and this: cpp Code:
into: cpp Code:
worked for me. |
|
#3
|
|||
|
|||
|
Quote: will I be good like you one day? How long have you been doing what you're doing? I just feel so overwhelming sometimes. Thank you very much. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Simple c++ class help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|