I have created this program with the class Rectangle, and i have gotten most of the errors out I think. However, I am getting these errors, which I do not know how to fix. I would really appreciate anyone's help if they could tell me how to fix this. Thanks.
Undefined symbols for architecture x86_64:
"Rectangle::totalPerimeter", referenced from:
Rectangle::summary() in main.o
Rectangle::getInfo() in main.o
"Rectangle::rectanglesCreated", referenced from:
Rectangle::process() in main.o
Rectangle::summary() in main.o
"Rectangle::totalArea", referenced from:
Rectangle::summary() in main.o
Rectangle::getInfo() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include <iostream>
using namespace std;
class Rectangle{
public:
Rectangle();
void displayMaxRectangles(){
cout << "The maximum number of rectangles that can be created is " << maxRectangles << endl;
}
void rectangleCharacters(){
cout << "Enter the desired border character of the rectangle." << endl;
cin >> borderCharacter;
cout << "Enter the desired filler character of the rectangle." << endl;
cin >> fillCharacter;
}
void process(){
do{
getInfo();
cout << "Would you like to display the rectangle?" << endl;
cin >> yesno;
while ((yesno != 'n') || (yesno != 'N')){
if ((yesno == 'y') || (yesno == 'Y')){
rectangleCharacters();
for (int j = 0; j < length; j++){
if ((j == 0) || (j == length - 1)){
for (int v = 0; v < length; v++){
cout << borderCharacter;
}
}
else{
for (int w = 0; w < width; w++){
if ((w == 0) || (w == width - 1)){
cout << borderCharacter;
}
else{
cout << fillCharacter;
}
}
}
}
}
}
cout << endl << endl;
rectanglesCreated++;
cout << "Would you like to create another rectangle?" << endl;
cin >> yesno;
if ((yesno == 'n') || (yesno == 'N')){
summary();
}
}while(rectanglesCreated < maxRectangles);
}
void summary(){
cout << endl << endl << endl;
cout << "Rectangles Built: " << rectanglesCreated << endl;
cout << "Average Area: " << (totalArea / rectanglesCreated) << endl;
cout << "Average Perimeter: " << (totalPerimeter / rectanglesCreated);
}
void getInfo(){
cout << "Enter the desired length of the rectangle." << endl;
cin >> length;
cout << "Enter the desired width of the rectangle." << endl;
cin >> width;
cout << "The perimeter of this rectangle is " << (length * 2) + (width * 2);
cout << "The area of this rectangle is " << (length * width);
totalPerimeter += (length * 2) + (width * 2);
totalArea += length * width;
}
private:
double length, width;
char borderCharacter, fillCharacter, yesno;
static const int maxRectangles;
static int rectanglesCreated;
static double totalPerimeter, totalArea;
const int MAX, MIN;
};
const int Rectangle::maxRectangles = 5;
Rectangle::Rectangle ():MAX(25), MIN(5){
length = 5;
width = 10;
borderCharacter = '#';
fillCharacter = '*';
}
int main(){
Rectangle rect;
rect.displayMaxRectangles();
rect.process();
rect.summary();
return 0;
}
|