expected constructor, destructor, or type conversion before '*'

Discussion in 'C++' started by Preben, Sep 20, 2006.

  1. Preben

    Preben Guest

    Hi,

    I get this error when trying to compile:
    --------
    # g++ -c KGreyImage.cpp
    KGreyImage.cpp:25: error: expected constructor, destructor, or type
    conversion before '*' token
    --------


    and the code is given here:
    --------
    #include <vector>

    /** defines fuer Funktion KGreyImage<T>::edges(), geben an, was nach der
    Berechnung des Gradientenbetrags
    // noch alles gemacht werden soll
    */
    #define SUPPRESS_NONMAXIMA 1
    #define DOUBLE_THRESHOLDING 2
    #define CANNY 3

    template<class T> class KGreyImage {

    private:

    /** diese structs werden von ::findDots() benoetigt*/
    struct point {
    double x;
    double y;
    double mindist[5];
    int neighbor[5];
    int direction[4];
    bool inGrid;
    };

    struct lrud {
    double x;
    double y;
    int index;
    };


    public:

    KGreyImage();
    KGreyImage(unsigned int cols, unsigned int rows);
    KGreyImage(KGreyImage<T>* pImage);
    KGreyImage(KGreyImage<T> &pImage);
    KGreyImage(const KGreyImage<T> &pImage);


    KGreyImage(T* pImage, unsigned int cols, unsigned int rows);

    KGreyImage( std::vector<T> zeile, char orient = 'x' );

    struct dotOutput {
    /** Position in Grid-Koordinaten */
    double gx, gy;
    /** Position in Bild-Koordinaten */
    double ix, iy;
    };

    /** Dotliste finden; stuerzt mit "Segmentation fault" ab, wenn im
    Bild noch
    weitere Daten als nur das Punktmuster enthalten sind
    Parameter gibt den ungefaehren horizontalen Abstand zwischen
    benachbarten
    Punkten an */
    dotOutput* findDots(const int distExpect, int& dotCount) const;
    };



    template<class T>
    KGreyImage<T>::KGreyImage() {}

    template<class T>
    KGreyImage<T>::KGreyImage(unsigned int cols, unsigned int rows) {}

    template<class T>
    KGreyImage<T>::KGreyImage(const KGreyImage<T>& pImage) {}

    template<class T>
    KGreyImage<T>::KGreyImage(KGreyImage<T>& pImage) {}

    template<class T>
    KGreyImage<T>::KGreyImage(KGreyImage<T>* pImage) {}

    template<class T>
    KGreyImage<T>::dotOutput * KGreyImage<T>::findDots(const int distExpect,
    int& dotCount) const {
    dotOutput* dotList = new dotOutput[dotCount];
    return dotList;
    }
    --------


    Why does gcc 4.1.1 expect a constructor in front of the *?
    It should just return a pointer to the new array of dotOutput's!



    Thanks in advance

    Preben
    Preben, Sep 20, 2006
    #1
    1. Advertising

  2. Preben wrote:
    > Hi,
    >
    > I get this error when trying to compile:
    > --------
    > # g++ -c KGreyImage.cpp
    > KGreyImage.cpp:25: error: expected constructor, destructor, or type
    > conversion before '*' token


    <snip>

    >
    >
    > Why does gcc 4.1.1 expect a constructor in front of the *?
    > It should just return a pointer to the new array of dotOutput's!


    Looks like a gcc bug. Try gcc newsgroup.

    Krishanu
    Krishanu Debnath, Sep 20, 2006
    #2
    1. Advertising

  3. Preben

    Earl Purple Guest

    Preben wrote:
    > Hi,
    >
    > I get this error when trying to compile:
    > --------
    > # g++ -c KGreyImage.cpp
    > KGreyImage.cpp:25: error: expected constructor, destructor, or type
    > conversion before '*' token
    > --------
    >
    >
    > and the code is given here:

    <snip>

    It would be easier if you told us which is line 25.
    Earl Purple, Sep 20, 2006
    #3
  4. Preben

    Greg Guest

    Preben wrote:
    > Hi,
    >
    > I get this error when trying to compile:
    > --------
    > # g++ -c KGreyImage.cpp
    > KGreyImage.cpp:25: error: expected constructor, destructor, or type
    > conversion before '*' token
    > --------
    >
    >
    > and the code is given here:
    > --------
    > #include <vector>
    >
    >
    > template<class T>
    > KGreyImage<T>::dotOutput * KGreyImage<T>::findDots(const int distExpect,
    > int& dotCount) const {
    > dotOutput* dotList = new dotOutput[dotCount];
    > return dotList;


    Within a class or function template, it is necessary label (with the
    "typename" keyword) any name-dependent type, such as "dotOutput". So in
    this case, the findDots function template declaration should be:

    template<class T>
    typename KGreyImage<T>::dotOutput *
    KGreyImage<T>::findDots(const int distExpect, int& dotCount) const
    {
    dotOutput* dotList = new dotOutput[dotCount];
    return dotList;
    }

    in order for it to compile.

    Greg
    Greg, Sep 20, 2006
    #4
  5. Preben

    Preben Guest

    > Within a class or function template, it is necessary label (with the
    > "typename" keyword) any name-dependent type, such as "dotOutput". So in
    > this case, the findDots function template declaration should be:
    >
    > template<class T>
    > typename KGreyImage<T>::dotOutput *
    > KGreyImage<T>::findDots(const int distExpect, int& dotCount) const
    > {
    > dotOutput* dotList = new dotOutput[dotCount];
    > return dotList;
    > }
    >
    > in order for it to compile.


    Thanks...

    I'll try to do that and see if that works (doesn't have the code on this
    computer).


    / Preben
    Preben, Sep 20, 2006
    #5
  6. Preben

    Greg Guest

    Preben wrote:
    > > Within a class or function template, it is necessary label (with the
    > > "typename" keyword) any name-dependent type, such as "dotOutput". So in
    > > this case, the findDots function template declaration should be:
    > >...
    > > in order for it to compile.

    >
    > Thanks...
    >
    > I'll try to do that and see if that works (doesn't have the code on this
    > computer).


    Well in the interests of not prolonging the suspense, I will reveal
    that I have already compiled your code (at least the part you posted)
    with my fix on my computer and did so successfully.

    Now, I will say that I had much more trouble understanding the
    comments. The spelling is simply atrocious.

    Greg

    ps. oh, :)
    Greg, Sep 20, 2006
    #6
  7. Preben

    Preben Guest

    Greg wrote:
    > Preben wrote:
    >>> Within a class or function template, it is necessary label (with the
    >>> "typename" keyword) any name-dependent type, such as "dotOutput". So in
    >>> this case, the findDots function template declaration should be:
    >>> ...
    >>> in order for it to compile.

    >> Thanks...
    >>
    >> I'll try to do that and see if that works (doesn't have the code on this
    >> computer).

    >
    > Well in the interests of not prolonging the suspense, I will reveal
    > that I have already compiled your code (at least the part you posted)
    > with my fix on my computer and did so successfully.
    >
    > Now, I will say that I had much more trouble understanding the
    > comments. The spelling is simply atrocious.
    >
    > Greg


    Oh, just found out that I hadn't removed all the german comments.

    And to reveal that I didn't write the code either - I'm just trying to
    make the 8 years of work compile on my gentoo workstation where I
    haven't got the possibility to go with gcc 3.3, which is the only
    compiler that the code compiles with!
    It's really a problem when every part of the code doesn't compile, files
    are many thousand lines and probably around 50 errors in each ;-(


    / Preben
    Preben, Sep 20, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Damien
    Replies:
    5
    Views:
    14,669
    Damien
    Dec 13, 2006
  2. algatt
    Replies:
    2
    Views:
    604
    John Harrison
    Jul 19, 2007
  3. Replies:
    1
    Views:
    315
    Victor Bazarov
    Oct 19, 2007
  4. Replies:
    5
    Views:
    23,658
  5. mhubbard
    Replies:
    0
    Views:
    3,430
    mhubbard
    Apr 4, 2008
Loading...

Share This Page