Hello im getting a segnementation fault and i dont know how to fix it ,i think it happens when i use new and i try to create a pointer to a class that i use in my project .Here is the code:
artifacts *artptr[10];
cout<<"just created a table of artifacts pointers"<<endl;
//paintings paint;
//artptr=new artifacts *[10];
for (int i=0;i<10;i++){
int length1;
length1=rand()%10+1;
int width1;
width1=rand()%10+1;
int volume1;
volume1=rand()%50+1;
cout<<"meta thn tyxaia arxikopoihsh timvn"<<endl;
if (rand()%2){
cout<<"creating a pointer to painting"<<endl;
//paintings *paint;
//artptr.push_back (new paintings(length,width,techValue));
artptr[i]=new paintings(length1,width1,techValue);
}
else{
cout<<"creating a pointer to sculpures"<<endl;
//artptr.push_back (new sculptures(volume,matValue));
artptr[i]=new sculptures(volume1,matValue);
}
}
where sculptures and paintings are derived classes of artifacts