Loo*_*oom 0 c++ arrays c-strings crt c++11
我想在MSVC2010中初始化零指针的c字符串数组
// Foo.h
#pragma once
class Foo {
int sz_;
char **arr_;
public:
Foo();
~Foo();
// ... some other functions
};
// Foo.cpp
#include "Foo.h"
#define INITIAL_SZ 20
Foo::Foo() : sz_(INITIAL_SZ) {
// there I have to initialize arr_ (dynamic array and can be enlarged later)
arr_ = (char **)calloc(INITIAL_SZ * sizeof (char *)); // ???
// or maybe arr_ = new ...
}
Run Code Online (Sandbox Code Playgroud)
如何正确初始化arr_?我不被允许使用STL,MFC等.
| 归档时间: |
|
| 查看次数: |
449 次 |
| 最近记录: |