Domanda

I am trying to create a class in C++ (I have not worked with classes in a long time!) and I am trying to create a few constructors in the following way:

#ifndef TAAP_HEAD
#define TAAP_HEAD

class TaaP
{
public:
  // default cosntructor
  Taap();

  // constructor with xyz
  Taap(double xyz[3]);

private:
  double m_xyz[3];
  double m_Rho;
  double m_GradRho[3];
  double m_HessRho[3][3];
  double m_EigenValues[3];
  double m_EigenVectors[3][3];
};
#endif

where Taap() will simply assign xyz to {0.0, 0.0, 0.0}, but Taap(double xyz[3]) will allow the user to input their own starting coordinate.

The error I get upon compilation is :

hdr_taap.h:9:8: error: ISO C++ forbids declaration of ‘Taap’ with no type [-fpermissive]
   Taap();
        ^
hdr_taap.h:12:21: error: ISO C++ forbids declaration of ‘Taap’ with no type [-fpermissive]
   Taap(double xyz[3]);
                     ^

Does this make any sense? I have tried to follow a lot of examples of class construction and cannot see anything I am doing wrong.

È stato utile?

Soluzione

C++ is case-sensitive. Change TaaP to Taap

Altri suggerimenti

Your problem is that the class is named TaaP and your constructors are named Taap (note the capitalisation). Constructors should have exactly the same name as the class they belong to.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top