Question: I have error message in following C++ assignment. it says (linker command failed with exit code 1 (use -v to see invocation)? // File Name:

I have error message in following C++ assignment. it says (linker command failed with exit code 1 (use -v to see invocation)?

// File Name: GeometricArea.cpp

#include

#include

#include

#include

using namespace std;

// Function to calculate area of a polygon

double polygonArea(double pointX[], double pointY[], int len)

{

// Initializes area to zero

double area = 0.0;

// Calculate value of shoelace formula

int pos = len - 1;

for (int c = 0; c < len; c++)

{

area += (pointX[pos] + pointX[c]) * (pointY[pos] - pointY[c]);

// pos is previous vertex to c

pos = c;

}// End of for loop

// Return absolute value

return (area / 2.0);

}// End of function

// File Name: SpecificationException.h

#ifndef SPECIFICATIONEXCEPTION_H

#define SPECIFICATIONEXCEPTION_H

#include

#include

using namespace std;

// Defines a class SpecificationException to handle polygon exception

class SpecificationException

{

public:

// Parameterized constructor definition

SpecificationException(string message)

{

// Displays error message

cout<

// Exit the program

exit(0);

}// End of constructor

};// End of class

#endif

// File Name: SpecificationException_test.cpp

#include

#include "SpecificationException.hpp"

#include "GeometricArea.cpp"

using namespace std;

// main function definition

int main()

{

// Variable to store sides

int sides;

// Accepts sides from the user

cout<<" Enter number of sides: ";

cin>>sides;

// Checks if sides is less than or equals to 2 then throws an exception

if(sides <= 2)

throw new SpecificationException("Error: Fewest number of sides of polygon can have 3.");

// Otherwise valid sides

// To store x and y coordinate values

double pointX[sides];

double pointY[sides];

cout<<" Enter the x and y coordinate values: ";

// Loops till number of sides and accept x and y coordinate values

for(int c = 0; c < sides; c++)

{

cout<<" X = ";

cin>>pointX[c];

cout<<" Y = ";

cin>>pointY[c];

}// End of for loop

// Calls the function to calculate area and displays it

cout <<" Area of Polygon having "<

}// End of main function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!