申請空間出錯
出錯在這一句,但是還是不懂為什么? Student *str = new Student; ? ?// 設置對象的數(shù)據(jù)成員 之前錯誤的句子寫的是 ? ? ? Student *str = new string;
出錯在這一句,但是還是不懂為什么? Student *str = new Student; ? ?// 設置對象的數(shù)據(jù)成員 之前錯誤的句子寫的是 ? ? ? Student *str = new string;
2018-03-05
舉報
2018-03-30
為對象申請空間需要在后面加個括號,比如:Student *str = new Student(); 但是為普通類型申請內存,可以沒有。如果加了括號則是初始化方法的一種,如:int *p=new int(2); //也就是*p=2;
2018-03-05
?Student *str = new Student();?