سلام دوستان
وقتی میخوام به یک شی از استراکت با استفاده از new در main حافظه بدم ،حافظه اختصاص داده نمیشه
#include <iostream>
#include <cstring>
using namespace std;
struct Student{
string name;
string family;
string ID;
double ave;
};
int main(){
struct Student *st1, st2[4];
int num;
cout << "how many student do you have? ";
cin >> num;
st1 = new struct Student[num];
return 0;
}
ولی به صورت معمولی که شی استراکت رو ارایه در نظر میگیرم مثل st2 حافظه داده میشه