473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 Gradientenbetra gs
// noch alles gemacht werden soll
*/
#define SUPPRESS_NONMAX IMA 1
#define DOUBLE_THRESHOL DING 2
#define CANNY 3

template<class Tclass 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(unsi gned int cols, unsigned int rows);
KGreyImage(KGre yImage<T>* pImage);
KGreyImage(KGre yImage<T&pImage );
KGreyImage(cons t KGreyImage<T&pI mage);
KGreyImage(T* pImage, unsigned int cols, unsigned int rows);

KGreyImage( std::vector<Tze ile, char orient = 'x' );

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

/** Dotliste finden; stuerzt mit "Segmentati on 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(unsi gned int cols, unsigned int rows) {}

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

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

template<class T>
KGreyImage<T>:: KGreyImage(KGre yImage<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
Sep 20 '06 #1
5 24708

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.

Sep 20 '06 #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
--------
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

Sep 20 '06 #3
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
Sep 20 '06 #4

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, :-)

Sep 20 '06 #5
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
Sep 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
19251
by: Zenon | last post by:
Folks, I cannot figure out why I am getting an error: Error E2303 EngineX.hpp 19: Type name expected. Here is my code. Can you please help? #ifndef EngineX__hpp #define EngineX__hpp #include<iostream> #include <cstring> #include <cmath>
5
21153
by: Damien | last post by:
Hi all, I'm using a pretty standard C++ Singleton class, as below: template <typename T> class Singleton { public: static T* Instance() {
2
2496
by: algatt | last post by:
Hello, I am trying to compile the TPIE files but there is a file that's constantly giving errors about the templates. I am using gcc 3.4.5 on Eclipse using Windows XP. The following is the code of the file that I am trying to compile: // Copyright (c) 1994 Darren Erik Vengroff // // File: ami_scan_mac.h // Author: Darren Erik Vengroff <dev@cs.duke.edu> // Created: 5/24/94 // // $Id: ami_scan_mac.h,v 1.10 2003/04/25 00:06:56 tavi Exp $
5
7969
by: amitmool | last post by:
hi, i have used the queue library file and try to use the template as template <class QueueItem> queue <QueueItem>::~queue() // line 25 { } template <class QueueItem> void queue<QueueItem>::push(const QueueItem& entry) // line 42
13
3952
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help is much appreciated. JD
12
7189
by: Rahul | last post by:
Hi Everyone, I have the following code and i'm able to invoke the destructor explicitly but not the constructor. and i get a compile time error when i invoke the constructor, why is this so? class Trial { public: Trial() {
2
3531
by: parvtb | last post by:
I have the following code: #include <list> using namespace std; template <typename T> list<T>::iterator doStuff( list<T>::iterator myIter ) //--error here
11
2362
by: Peter Jansson | last post by:
Dear newsgroup, In the following code, it looks as though the exception thrown in the constructor is not caught properly. I get this output: ---- standard output ---- Base() constructor. Exception in Base(): "Going down (B can't be construced properly)!" (the exception has now been dealt with).
10
15754
by: preeya | last post by:
Hi, I have written the following program: ------------------------------------------------------------------------------------------------------------- 1 #include <stdio.h> 2 #include "abc.h" 3 4 void PROP_abc(double ptr)
0
8115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8053
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8557
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8380
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1638
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.