简单的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;

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