Question

In: Computer Science

I am getting the fallowing error when I compile my application: mingw32-g++.exe -Wall -fexceptions -g -c...

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 <iostream>

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 <iostream>
#include "Circle.h"
#include "Shape.h"

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: "<<getSgapeId()<<endl;
cout<<"Shape Type: "<<getShapeType()<<endl;
cout<<"Unit of Measure: "<<getUnitOfMeasure();
cout<<"Area: "<<getArea()<<endl;
cout<<endl;
}
}


#################################################################################################################################

#include <iostream>
#include "Square.h"
#include "Shape.h"

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: "<<getSgapeId()<<endl;
cout<<"Shape Type: "<<getShapeType()<<endl;
cout<<"Unit of Measure: "<<getUnitOfMeasure();
cout<<"Area: "<<getArea()<<endl;
cout<<endl;
}
}

####################################################################################################################################

#include <iostream>
#include "Square.h"
#include "Circle.h"
#include "Shape.h"

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

##############################################################################################################################

Solutions

Expert Solution

// Here is compilable code. There were multiple mistake and it is difficult to highlisht them. Use some diff tool to see exact changes.

// Shape.h

#ifndef SHAPE_H_INCLUDED
#define SHAPE_H_INCLUDED
#include <iostream>
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

// Circle.h

#ifndef AREACIRCLE_H_INCLUDED
#define AREACIRCLE_H_INCLUDED
#include "Shape.h"
using namespace std;
/* Circle Class */
class Circle:public Shape
{
private:
float radius;
public:
Circle();
Circle(string id, float rad);
Circle(string id, string type, string unit, float rad);
float getArea();
void display();
/* 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

// Circle.cpp

#include <iostream>
#include "Circle.h"
#include "Shape.h"
#include <math.h>
using namespace std;
/* Constructor */
Circle::Circle():Shape()
{
radius = 0;
}
/* Copy Constructor, which takes a parameter */
Circle::Circle(string id, float rad):Shape(id)
{
radius = rad;
}
Circle::Circle(string id, string type, string unit, float rad): Shape(id, type, unit){
radius = rad;
}
/* Method to calculate the area of circle */
float Circle::getArea()
{
return M_PI*radius*radius;
}
void Circle::display(){
cout<<"Shape Id: "<<getSgapeId()<<endl;
cout<<"Shape Type: "<<getShapeType()<<endl;
cout<<"Unit of Measure: "<<getUnitOfMeasure();
cout<<"Area: "<<getArea()<<endl;
cout<<endl;
}

// Square.h

#ifndef AREASQUARE_H_INCLUDED
#define AREASQUARE_H_INCLUDED
#include "Shape.h"
using namespace std;
class Square:public Shape
{
private:
float sidelen;
public:
Square();
Square(string id, float rad);
Square(string id, string type, string unit, float rad);
float getArea();
void display();
/* get the value of length */
float getLength()
{
return sidelen;
}
/* set value for length */
void setLength(float l)
{
sidelen = l;
}
};
#endif // AREASQUARE_H_INCLUDED

//Square.cpp

#include <iostream>
#include "Square.h"
#include "Shape.h"
using namespace std;
Square::Square():Shape()
{
sidelen = 0;
}
/* Copy Constructor, which takes a parameter */
Square::Square(string id, float l):Shape(id)
{
sidelen = l;
}
Square::Square(string id, string type, string unit, float l): Shape(id, type, unit)
{
sidelen = l;
}
/* Method to calculate the area of circle */
float Square::getArea()
{
return sidelen * sidelen;
}
void Square::display()
{
cout<<"Shape Id: "<<getSgapeId()<<endl;
cout<<"Shape Type: "<<getShapeType()<<endl;
cout<<"Unit of Measure: "<<getUnitOfMeasure();
cout<<"Area: "<<getArea()<<endl;
cout<<endl;
}

// main.cpp

#include <iostream>
#include "Square.h"
#include "Circle.h"
#include "Shape.h"
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;
Square sq = Square();
Circle c = Circle();
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;
//Circle c = Circle();
c.setRadius(rad);
c.setShapeId(id);
c.setUnitOfMeasure(unit);
c.setShapeType("Circle");
cout << "Area of Circle : " << c.getArea() << endl;
c.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;
//Square sq = Square();
sq.setLength(l);
sq.setShapeId(id);
sq.setShapeType("Square");
sq.setUnitOfMeasure(unit);
sq.display();
cout << "Area of Square : " << sq.getArea() << endl;
break;
}
} while(menuOption!=0);
cout << endl<< endl << "============== THANK YOU ===================" << endl<< endl;
return 0;
}

// Here is link for code https://goo.gl/lkxddo

sh-4.2$ g++ *.cpp *.h

sh-4.2$


Related Solutions

I am having trouble with my assignment and getting compile errors on the following code. The...
I am having trouble with my assignment and getting compile errors on the following code. The instructions are in the initial comments. /* Chapter 5, Exercise 2 -Write a class "Plumbers" that handles emergency plumbing calls. -The company handles natural floods and burst pipes. -If the customer selects a flood, the program must prompt the user to determine the amount of damage for pricing. -Flood charging is based on the numbers of damaged rooms. 1 room costs $300.00, 2 rooms...
I'm getting an error with my code on my EvenDemo class. I am supposed to have...
I'm getting an error with my code on my EvenDemo class. I am supposed to have two classes, Event and Event Demo. Below is my code.  What is a better way for me to write this? //******************************************************** // Event Class code //******************************************************** package java1; import java.util.Scanner; public class Event {    public final static double lowerPricePerGuest = 32.00;    public final static double higherPricePerGuest = 35.00;    public final static int cutOffValue = 50;    public boolean largeEvent;    private String...
Syntax error in C. I am not familiar with C at all and I keep getting...
Syntax error in C. I am not familiar with C at all and I keep getting this one error "c error expected identifier or '(' before } token" Please show me where I made the error. The error is said to be on the very last line, so the very last bracket #include #include #include #include   int main(int argc, char*_argv[]) {     int input;     if (argc < 2)     {         input = promptUserInput();     }     else     {         input = (int)strtol(_argv[1],NULL, 10);     }     printResult(input);...
This is in Python I am getting an error when I run this program, also I...
This is in Python I am getting an error when I run this program, also I cannot get any output. Please help! #Input Section def main(): name=input("Please enter the customer's name:") age=int(input("Enter age of the customer: ")) number_of_traffic_violations=int(input("Enter the number of traffic violations: ")) if age <=15 and age >= 105: print('Invalid Entry') if number_of_traffic_violations <0: print('Invalid Entry') #Poccessing Section def Insurance(): if age < 25 and number_of_tickets >= 4 and riskCode == 1: insurancePrice = 480 elif age >=...
What is the significance of -c , -g, -Wall and -o switches when we compile C/C++...
What is the significance of -c , -g, -Wall and -o switches when we compile C/C++ code ?
Hi I am getting error in implement some test case using Java. I am adding my...
Hi I am getting error in implement some test case using Java. I am adding my code and relevant files here, and the failed test. Please let me know where my problem is occuring and fix my code. Thanks! I will upvote. Implement a class to perform windowing of a Hounsfield value Implement the class described by this API. A partial implementation is provided for you in the eclipse project; however, unlike the previous class, very little work has been...
Getting an error with my for loop.  How do I correct it?  I am supposed to: Continuously prompt...
Getting an error with my for loop.  How do I correct it?  I am supposed to: Continuously prompt for the number of minutes of each Rental until the value falls between 60 and 7,200 inclusive. For one of the Rental objects, create a loop that displays Coupon good for 10percent off next rental as many times as there are full hours in the Rental. ///////////////////////////////RentalDemo package java1; import java.util.Scanner; public class RentalDemo { public static void main(String[] args) {    Rental object1 =...
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile and Execute. The...
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile and Execute. The project is below, I have supplied the code and I'm getting an error in SavingsAccount.h file. 17   5   C:\Users\adam.brunell\Documents\Classes\C++\Week4\SavingsAccount.h   [Error] 'SavingsAccount::SavingsAccount(std::string, double, double)' is protected A.Assume i.SavingsAccount: Assume an Interest Rate of 0.03 ii.HighInterestSavings: Assume an Interest Rate of 0.05, Minimum Balance = $2500 iii.NoServiceChargeChecking: Assume an Interest Rate = 0.02, Minimum of Balance = $1000 iv.ServiceChargeChecking – Assume account service charge = $10,...
Why am I getting this error using 000webhost , but I do not get this error...
Why am I getting this error using 000webhost , but I do not get this error running XAMPP? Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd2/006/14881006/public_html/test/index.php:1) in /storage/ssd2/006/14881006/public_html/test/index.php on line 8 Code is below. ******************************************************************************************************************** <!DOCTYPE html> <?php    //Determine if the submit button has been clicked to set the cookie name and value    if (isset($_POST['name'])){            $cookie_name = $_POST['name'];            $cookie_value = $_POST['value'];            setcookie($cookie_name, $cookie_value,...
How to compile this code on Visual Studio? Because it keeps getting me an error when...
How to compile this code on Visual Studio? Because it keeps getting me an error when i compile it. #include<iostream.h> #include<cio.h> class Array { public: Array(int=0)//initalise the array with 0 value Array(const Array &); ~Array(); private: int size; int *arr; bool setvalue(int index,int value); bool getvalue(int index,int &value); Array & increment(); int getsize(); void print(); Array &Add(const Array arr); bool Equal(const Array *arr)const; Array &removeAt(int index); Array &insertAt(int index,int value); }; //End of Array class void Array::setvalue(int index,int value) //set...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT