2
0

More than 5 years have passed since last update.

C++でNULLを使う最低限のこと

Posted at

NULL を使うために

クラスヘッダのみincludeしたクラスをコンパイルしたところ、
NULLが定義されてないとコンパイラエラーが起きた。

調べてみると、NULLはプリミティブ型ではないため、
NULLを定義したヘッダファイルをincludeする必要があるらしい。

NULL が使いたいだけなので、最小限のヘッダファイルを確認したところ
cstddef に定義されていた。そこで、以下の一行を加えてNULLを利用できた。

#include <cstddef>

参考

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0