...

Embed: (wiki syntax)

« Back to documentation index

Shape Class Reference

Shape Class Reference

A library to create square and rectangle objects. More...

#include <Shape.h>

Public Member Functions

 Shape (int x)
 create an object for square
 Shape (int x, int y)
 create an object for rectangle
int getArea ()
 returns to area of rectangle/square
int getPerimeter ()
 returns to perimeter of rectangle/square

Detailed Description

A library to create square and rectangle objects.

calculates the area and perimeter

Example:

 #include "mbed.h"
 #include "Shape.h"
 
 Shape rect(3,4);
 Shape squr(1);
 
 int main() {
     printf(" area of rect = %d \n", rect.getArea());
     printf("perimeter of square = %d \n", squr.getPerimeter());
 }

Definition at line 27 of file Shape.h.


Constructor & Destructor Documentation

Shape ( int  x )

create an object for square

Parameters:
xinteger value for a side on square

Definition at line 4 of file Shape.cpp.

Shape ( int  x,
int  y 
)

create an object for rectangle

Parameters:
xinteger value for length of rectangle
yinteger value for breadth of rectangle

Definition at line 9 of file Shape.cpp.


Member Function Documentation

int getArea (  )

returns to area of rectangle/square

Returns:
returns the area of rectangle/square

Definition at line 13 of file Shape.cpp.

int getPerimeter (  )

returns to perimeter of rectangle/square

Returns:
returns the perimeter of rectangle/square

Definition at line 20 of file Shape.cpp.