簡單的C++動態分配數組

#include<iostream>
using namespace std;
int main()
{
    int* m=new int(30);//此處是動態聲明 一個指向整數的指針 
    //* m=50;//這句話若生效,輸出的是50,現在是失效狀態,輸出30 
    cout<<"* m:"<<*m<<endl;
    float *floatptr=new float;
    *floatptr=0.5; 
    cout<<"*floatptr:"<<* floatptr<<endl;
    delete m;
    delete floatptr;
    return 0;

}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章