Nik*_*ola 3 c++ pointers stl list
我在c中有列表指针:
list<int> * pointer = (list<int> *)malloc(sizeof(list<int>));
Run Code Online (Sandbox Code Playgroud)
当我尝试:
pointer->push_back(1);
Run Code Online (Sandbox Code Playgroud)
我得到错误,因为malloc不调用列表构造函数.我知道用c ++执行此操作:
list<int> * pointer = new list<int>();
Run Code Online (Sandbox Code Playgroud)
但我需要这个在c?
有人知道解决方案吗?
不,因为这些是不同的语言.只是因为在名称中的公共字母之后只有文本字符串"++"并不意味着什么 - 这与尝试在Python中使用Java容器相当.
如果要使用STL,则必须使用C++编译器.
| 归档时间: |
|
| 查看次数: |
568 次 |
| 最近记录: |