相关疑难解决方法(0)

在C++标识符中使用下划线有哪些规则?

在C++中通常用某种前缀命名成员变量来表示它们是成员变量而不是局部变量或参数.如果你来自MFC背景,你可能会使用m_foo.我myFoo偶尔也见过.

C#(或者可能只是.NET)似乎建议只使用下划线,如_foo.这是否允许C++标准?

c++ standards naming-conventions c++-faq

906
推荐指数
4
解决办法
24万
查看次数

基类具有不完整的类型

我有一个Point我继承的基类Point3D.但是,由于某种原因,类Point必须始终返回Point3D操作add,因此我将其包含在我的包含中.

这是我的班级Point:

#ifndef POINT_H
#define POINT_H

#include "Point3D.hpp"

class Point{

  public:
    Point(double, double, double);

    void print() const;
    Point3D add( const Point& );

  protected:
    double mX;
    double mY;
    double mZ;

};

#endif
Run Code Online (Sandbox Code Playgroud)

在我的班上Point3D,我知道我还没有遇到过Point我第一次被调用的定义(因为Point3D它包含在Point标题中),所以我定义class Point;,然后我定义我将使用的部分Point:

#ifndef POINT3D_H
#define POINT3D_H

#include <iostream>
#include "Point.hpp"  // leads to the same error if ommitted

class Point;    

class Point3D : public Point …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance

0
推荐指数
1
解决办法
6725
查看次数