ich habe folgendes Problem:
ich versuche eine Sinusfunktion so oft wie ich möchte zu plotten und jedes mal soll die X-Breiche [xmin, xmax] über die Konsol eingeben ;
beim ersten Aufruf funktionert ohne Problem aber danach sobald ich in die Schleife reingehe und die xmin und xmax eingebe meldet mir ein Speicherzugriffsproblem;
hier sind Abschnitte von meinem Code
plott.h
Code: Alles auswählen
struct Vpair{
double x;
double y;
Vpair(double x, double y):x(x),y(y){}
};
class Funcplott: public QWidget{
public:
Parser(int n, QWidget *p=0,Qt::WindowFlags f=0);
void setValue( const std::vector<Vpair> &v);
protected:
virtual void paintEvent( QPaintEvent *ev);
class DATA{
public
std::vector<Vpair> Dataplot(int psize);
Code: Alles auswählen
Funcplott::Funcplott( int n, QWidget *p, Qt::WindowFlags f )
: QWidget( p, f ) {
valueNo = n;
for ( int i=0; i<n; i++ ){
values.push_back( Vpair(0, 0));
}
}
std::vector<Vpair> DATA::Dataplot(int psize){
double xr=(double)(xmax-xmin)/psize;
double X=xmin;
int i;
std::vector<Vpair> dpt;
X=xmin;
for(i=0; i<psize; i++){
dpt.push_back(XYPair(X,sin(X)));
X+=xr;
}
return dpt;
}
Code: Alles auswählen
int main( int argc, char *argv[])
{
int Wahl;
DATA Data;
QApplication myapp(argc, argv);
std::vector<Vpair> V;
Funcplott* plotWind = new Funcplott(psize);
plotWind->resize(psize,psize);
Data.setvalue(); // setze Xmin und Xmax
V=Data.Dataplot(psize);
plotWind->setValue(V);
plotWind->show();
myapp.exec();
do{
cout<<"Bitte geben Sei ein: 1 für die Funktion neu zuplotten , 2 für Plott zu verlassen"<<endl;
cin>>Wahl;
switch(Wahl){
case 1:
Data.setvalue(); // setze Xmin und Xmax
V=Data.Dataplot(psize);
plotWind->setValue(V);
plotWind->show();
myapp.exec();
break;
default: cout<<"falsche Zeichen eingegeben"<<endl;
}
}while(Wahl!=2);
Danke im Voraus
Gruß
Seb