I basically took code from the textbook and modified it to give me n-sided polygon.
However, when i loop. I need to delete the previous polygon so that the new polygon can be drawn. I tried calling delete. But I get an error saying expected pointers. Once the polygon is drawn. and I click next, and enter the new number. The program crashes. Is there a way to delete the polygon so that the next polygon can be drawn?
#include "Simple_window.h" // get access to our window library
#include "Graph.h" // get access to our graphics library facilities
#include <math.h>
#include <iostream>
#include <limits>
usingnamespace std;
int main(){
Simple_window win(Point(100,100),600,400,"Marks");
Graph_lib::Polygon poly ;
bool over = true;
int n = 0;
while(over){
Marks pp("x");
pp.add(Point(300,200));
cout<<"Enter number of sides (3 or more): ";
while(!(cin>>n)){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout<<"Enter number of sides (3 or more): ";
}
if(n<3){
break;
}
//Finding the numbers of angles.
if(n%2 != 0){
for(int i = 0 ; i < n ; i++){
if(i==0){
while(degree!=270){
degree++;
}
}
//Logic for angles.
}
}else{
//Logic for programming polygon
}
}
poly.set_color(Color::magenta); // adjust properties of poly
win.attach (poly); // connect poly to the window
win.attach(pp);
win.wait_for_button(); // Display!
}
}