class MyClass
{
public:
int price;
MyClass()
{
cin>>price;
}
};
class Evet
{
public:
std::vector<MyClass*> v;
double overall()
{
int n;
int sum = 0;
cout<<"Enter how many"<<endl;
cin>>n;
v.push_back(new MyClass [n]);
for(int i = 0; i < n; i++)
{
cout<<v[i]->price<<endl;
}
}
};
int main()
{
Evet e;
e.overall();
return 0;
}
I get segmentation fault(core dumped) when trying to cout V[i>0]->price
What am I doing wrong