点未被宣布

时间:2014-01-05 14:54:47

标签: c++

这是错误: 我不知道为什么这个奇怪的错误! '点'& 'Vector'是类的“Droite3D”属性! 请帮忙

    ******************************* Droite3D.h**************************



#ifndef DROITE3D_H
#define DROITE3D_H
#include<iostream>
#include<Point3D.h>
#include<Vecteur3D.h>``

class Droite3D
{
    Point3D Point;
    Vecteur3D Vecteur;

    public:

    Droite3D(Point3D p, Vecteur3D v){
        Point=p;
        Vecteur=v;
    }

    void afficher();
    void afficher ( ostream & out) const;
};

** * ** * ** * 的** * ** * Droite3D.cpp * * ** * * * * ** * ** * **

#include "Droite3D.h"
#include<iostream>

ostream & operator<< (ostream & out, const Droite3D &D)
{
    D.afficher (out);
    return out;
}
}

void afficher ( ostream & out) const{
    cout <<"\nc'est la droite definie par le point "<<Point<<" et le vecteur "<<Vecteur;

2 个答案:

答案 0 :(得分:1)

afficherDroite3D的成员,因此您需要将其定义放在该范围内:

void Droite3D::afficher ( ostream & out) const
{//  ^^^^^^^^^^
  out <<"\nc'est la droite definie par le point "
       <<Point<<" et le vecteur "<<Vecteur;
}

否则,您定义的是非成员afficher,它显然对PointVecteur一无所知。

请注意,您还希望流式传输到out,而不是cout

答案 1 :(得分:1)

请在使用类::的变量定义方法afficher时使用范围解析运算符Droite3D,因此您需要提及其范围。

相关问题