Question
I am getting the fallowing error when I compile my application: mingw32-g++.exe -Wall -fexceptions -g -c E:vmmarAreaareamain.cpp -o objDebugmain.o E:vmmarAreaareamain.cpp: In function 'int main()': E:vmmarAreaareamain.cpp:41:15:
I am getting the fallowing error when I compile my application:
mingw32-g++.exe -Wall -fexceptions -g -c E:\vmmar\Area\area\main.cpp -o obj\Debug\main.o
E:\vmmar\Area\area\main.cpp: In function 'int main()':
E:\vmmar\Area\area\main.cpp:41:15: error: 'setRadius' was not declared in this scope
setRadius(rad);
^
E:\vmmar\Area\area\main.cpp:42:15: error: 'setShapeId' was not declared in this scope
setShapeId(id);
^
E:\vmmar\Area\area\main.cpp:43:23: error: 'setUnitOfMeasure' was not declared in this scope
setUnitOfMeasure(unit);
^
E:\vmmar\Area\area\main.cpp:44:23: error: 'setShapeType' was not declared in this scope
setShapeType("Circle");
^
E:\vmmar\Area\area\main.cpp:45:41: error: 'getArea' was not declared in this scope
cout << "Area of Circle : " << getArea() << endl;
^
E:\vmmar\Area\area\main.cpp:46:10: error: 'display' was not declared in this scope
display();
^
E:\vmmar\Area\area\main.cpp:57:13: error: 'setLength' was not declared in this scope
setLength(l);
^
Process terminated with status 1 (0 minute(s), 0 second(s))
7 error(s), 0 warning(s) (0 minute(s), 0 second(s))
######################################################################################################################
The following is my entire application:
#ifndef SHAPE_H_INCLUDED #define SHAPE_H_INCLUDED #include
using namespace std; const float PI = 3.1415926;
class Shape{ private: string shapeType; string shapeId; string unit_of_measure;
public: Shape(){} Shape(string id){ shapeId = id; } Shape(string Id, string type, string unit){ shapeId = Id; shapeType = type; unit_of_measure= unit; }
string getShapeType(){ return shapeType; }
string getSgapeId(){ return shapeId; }
string getUnitOfMeasure(){ return unit_of_measure; }
void setShapeType(string type){ shapeType = type; } void setShapeId(string id){ shapeId = id; } void setUnitOfMeasure(string unit){ unit_of_measure = unit; }
virtual float getArea() = 0; };
#endif // SHAPE_H_INCLUDED
############################################################################################################################### #ifndef AREACIRCLE_H_INCLUDED #define AREACIRCLE_H_INCLUDED #include "Shape.h"
using namespace std;
/* Circle Class */ class Circle:public Shape { private: float radius; public: /* set value for radius */ void setRadius(float rad) { radius = rad; } /* get the value of radius */ float getRadius() { return radius; } // float radius; }; //float areaCircle;
#endif // AREACIRCLE_H_INCLUDED
############################################################################################################################### #ifndef AREASQUARE_H_INCLUDED #define AREASQUARE_H_INCLUDED #include "Shape.h"
using namespace std;
class Square:public Shape { private: float sidelen; public: /* get the value of length */ float getLength() { return sidelen; } /* set value for length */ void setLength(float l) { sidelen = l; } };
#endif // AREASQUARE_H_INCLUDED
################################################################################################################################
#include
using namespace std;
/* Constructor */ Circle():Shape() { { radius = 0; } /* Copy Constructor, which takes a parameter */ Circle(string id, float rad):Shape(id) { radius = rad; }
Circle(string id, string type, string unit, float rad): Shape(id, type, unit){ radius = rad; } /* Method to calculate the area of circle */ float getArea() { return PI*radius*radius; }
void display(){ cout<<"Shape Id: "< ################################################################################################################################# #include using namespace std; Square():Shape() { { sidelen = 0; } /* Copy Constructor, which takes a parameter */ Square(string id, float l):Shape(id) { sidelen = l; } Square(string id, string type, string unit, float l): Shape(id, type, unit) { sidelen = l; } /* Method to calculate the area of circle */ float getArea() { return sidelen * sidelen; } void display() { cout<<"Shape Id: "< #################################################################################################################################### #include using namespace std; int main() { /*Circle = circle1; Square = square1; */ float rad; float l ; int menuOption; string id, type, unit; do { // Starting of while loop cout << endl << "=========CALCULATE AREA================" << endl; cout<< endl << "Select an Object" << endl << " 1: Circle" << endl << " 2: Square" << endl << " 0: Exit" << endl << " Enter Your Choice: "; cin >> menuOption; switch(menuOption) { case 1: cout<<"Enter shape id: "; cin>>id; cout<<"Enter unit of measure: "; cin>>unit; cout<< "Enter radius of the circle : "; // float rad; cin >> rad; setRadius(rad); setShapeId(id); setUnitOfMeasure(unit); setShapeType("Circle"); cout << "Area of Circle : " << getArea() << endl; display(); break; case 2: cout<<"Enter shape id: "; cin>>id; cout<<"Enter unit of measure: "; cin>>unit; cout<< "Enter length of one side of the square : "; //float l ; cin >> l; setLength(l); setShapeId(id); setShapeType("Square"); setUnitOfMeasure(unit); display(); cout << "Area of Square : " << getArea() << endl; break; } } while(menuOption!=0); { cout << endl<< endl << "============== THANK YOU ===================" << endl<< endl; return 0; } } ##############################################################################################################################
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started