小编Dav*_*vid的帖子

我可以为 vector<double> 函数返回 NULL 吗?

我有以下功能:

/* Calculate if there is an intersection with given intial position and 
  direction */
vector<double> intersection(vector<double> startPos, vector<double> direction)
{
   if(there is intersection)
      return (intersection coordinates);
   else {
      return NULL;
   }
} 
Run Code Online (Sandbox Code Playgroud)

我可以这样做并检查NULL是否存在交叉点:

vector<double> v = intersection(pos, dir);
if(v == NULL)
   /* Do something */
else
   /* Do something else */
Run Code Online (Sandbox Code Playgroud)

如果这是不允许的/糟糕的编码实践,我可以采取的另一种方法是什么?

c++ null vector

4
推荐指数
1
解决办法
6750
查看次数

标签 统计

c++ ×1

null ×1

vector ×1