473,395 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Abstract-Class Problem

Hello everyone,
I am currently having problems with a C++ abstract class. I have a
class FrameWork.h which defines some methods (of which some are
abstract, i.e. virtual void method() = 0). In FrameWork.cpp I define
some of the methods while I naturally leave the abstract methods
undefined. Now I wrote a class FrameWork_GUI.h which inherits from the
abstract FrameWork class and implements the missing (so far abstract)
methods. Furthermore, I would like to define some methods in other
classes, which expect an object of the base-class-type. So far so good.
In order to be sure that something like this was working the way i
thought it could work, I tried all this in a small test-class where it
worked perfectly well. However, in my real application I get the
compiler error telling me that
"error: expected `)' before '*' token" together with
"error: ISO C++ forbids declaration of 'FrameWork' with no
type" and later on
"error: 'FrameWork' has not been declared"

so I guess it should only be a minor problem here. I checked the
inlcudes and they should be fine...

OK, here are the classes which work:

Base-Class:
#ifndef _test_
#define _test_

#include <iostream>

class Test {
public:
virtual void first() =0;
void second() {
std::cout << "second Method\n";
}
};
#endif

Child-Class:
#ifndef _test_child_
#define _test_child_

#include "test.cpp"
class Test_child : public Test {
public:
void first() {
std::cout << "first\n";
}
};
#endif

The class usig the base-class in a method parameter:
#include "test.cpp"
#include "test_child.cpp"
#include <iostream>

class Using{
public:
void use(Test* tmp) {
std::cout << "call from using..";
tmp->first();
}
};

int main (int argc, char * const argv[]) {
Test_child tst;
Using u;
u.use(&tst);
}

--------------------------------------------------------------------------
Now let's come to my problem-children of today:

Base-Class-Header:
#ifndef _FrameWork_
#define _FrameWork_

#include <iostream>
#include <fstream>

class FrameWork{
public:
void init();
virtual void output(int type, std::string) = 0;
private:
ModelContainer* models;
};
#endif /*_FrameWork_*/

Base-Class-Cpp:
#include "FrameWork.h"

void FrameWork::init() {
models = new ModelContainer(this);
std::cout << "initializing";
}

////////////////////////////////////////////

Child-Class-Header:
#ifndef _FrameWork_GUI_
#define _FrameWork_GUI_

#include "FrameWork.h"

class FrameWork_GUI : public FrameWork{
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

Child-Class-Cpp:
#include "FrameWork_GUI.h"

void FrameWork_GUI::output(int type, std::string str) {
std::cout << str;
}
// OK, the class ModelContainer is waiting for a FrameWork-Object in
its Constructor.
// The errors I get during compiling relate to this class exactly there
where I use the FrameWork-object
// and tell me that FrameWork would not be defined.

Usage-Class-Header (ModelContainer):

class ModelContainer {
public:
ModelContainer(FrameWork* crd2);
private:
FrameWork* crd;
};
Usage-Class-Cpp:
ModelContainer::ModelContainer(FrameWork* crd2) {
crd=crd2;
}

OK, last thing here would be the relevant part of my Makefile. Do I
need the FrameWork.o in there as well? I was not sure because it was
abstract.. However, if I put it in there or not.. I get the same
errors..

ADDOBJS= FrameWork_GUI.o \
ModelContainer.o

LDFLAGS = -lraw1394 -ldc1394_control -ljpeg
main:main.o $(ADDOBJS)
@g++ -o main $(LDFLAGS) $+

Ok, this should be everything. I tried to give you as much code as
needed, hopefully it is enough.

Hope you guys can help, I have been struggling with all this for quite
some time..

Greetings and thanks a lot in advance
Tim

Aug 15 '06 #1
9 5473
silversurfer2025 wrote:
Hello everyone,
I am currently having problems with a C++ abstract class. I have a
class FrameWork.h which defines some methods (of which some are
abstract, i.e. virtual void method() = 0). In FrameWork.cpp I define
some of the methods while I naturally leave the abstract methods
undefined. Now I wrote a class FrameWork_GUI.h which inherits from the
abstract FrameWork class and implements the missing (so far abstract)
methods. Furthermore, I would like to define some methods in other
classes, which expect an object of the base-class-type. So far so good.
In order to be sure that something like this was working the way i
thought it could work, I tried all this in a small test-class where it
worked perfectly well. However, in my real application I get the
compiler error telling me that
"error: expected `)' before '*' token" together with
"error: ISO C++ forbids declaration of 'FrameWork' with no
type" and later on
"error: 'FrameWork' has not been declared"

so I guess it should only be a minor problem here. I checked the
inlcudes and they should be fine...

OK, here are the classes which work:

Base-Class:
#ifndef _test_
#define _test_

#include <iostream>

class Test {
public:
virtual void first() =0;
void second() {
std::cout << "second Method\n";
}
};
#endif

Child-Class:
#ifndef _test_child_
#define _test_child_

#include "test.cpp"
class Test_child : public Test {
public:
void first() {
std::cout << "first\n";
}
};
#endif

The class usig the base-class in a method parameter:
#include "test.cpp"
#include "test_child.cpp"
#include <iostream>

class Using{
public:
void use(Test* tmp) {
void used(Test & tmp) { // More like that in C++ ...
std::cout << "call from using..";
tmp->first();
tmp.first();
}
};

int main (int argc, char * const argv[]) {
Test_child tst;
Using u;
u.use(&tst);
u.use(tst);
}

--------------------------------------------------------------------------
Now let's come to my problem-children of today:

Base-Class-Header:
#ifndef _FrameWork_
#define _FrameWork_

#include <iostream>
#include <fstream>

class FrameWork{
public:
void init();
Note: this function is *not* virtual, nor inline, thus you will need to
compile framework.cpp
virtual void output(int type, std::string) = 0;
private:
ModelContainer* models;
};
#endif /*_FrameWork_*/

Base-Class-Cpp:
#include "FrameWork.h"

void FrameWork::init() {
models = new ModelContainer(this);
std::cout << "initializing";
}

////////////////////////////////////////////

Child-Class-Header:
#ifndef _FrameWork_GUI_
#define _FrameWork_GUI_

#include "FrameWork.h"
It is bad practice to put upper-case in include names as it tend to
change when you go from one system to another ... (just a
recommendation, I recently had another case-hell because of that ...)
>
class FrameWork_GUI : public FrameWork{
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

Child-Class-Cpp:
#include "FrameWork_GUI.h"

void FrameWork_GUI::output(int type, std::string str) {
std::cout << str;
}
// OK, the class ModelContainer is waiting for a FrameWork-Object in
its Constructor.
// The errors I get during compiling relate to this class exactly there
where I use the FrameWork-object
// and tell me that FrameWork would not be defined.

Usage-Class-Header (ModelContainer):
class FrameWork;
class ModelContainer {
public:
ModelContainer(FrameWork* crd2);
private:
FrameWork* crd;
};
Usage-Class-Cpp:
#include "FrameWork.h"
ModelContainer::ModelContainer(FrameWork* crd2) {
crd=crd2;
}

OK, last thing here would be the relevant part of my Makefile. Do I
need the FrameWork.o in there as well? I was not sure because it was
abstract.. However, if I put it in there or not.. I get the same
errors..
Yes, you need FrameWork.o as not all the methods are pure virtual ...
>
ADDOBJS= FrameWork_GUI.o \
ModelContainer.o

LDFLAGS = -lraw1394 -ldc1394_control -ljpeg
main:main.o $(ADDOBJS)
@g++ -o main $(LDFLAGS) $+

Ok, this should be everything. I tried to give you as much code as
needed, hopefully it is enough.

Hope you guys can help, I have been struggling with all this for quite
some time..

Greetings and thanks a lot in advance
Tim
Pierre
Aug 15 '06 #2

Pierre Barbier de Reuille wrote:
silversurfer2025 wrote:
Hello everyone,
I am currently having problems with a C++ abstract class. I have a
class FrameWork.h which defines some methods (of which some are
abstract, i.e. virtual void method() = 0). In FrameWork.cpp I define
some of the methods while I naturally leave the abstract methods
undefined. Now I wrote a class FrameWork_GUI.h which inherits from the
abstract FrameWork class and implements the missing (so far abstract)
methods. Furthermore, I would like to define some methods in other
classes, which expect an object of the base-class-type. So far so good.
In order to be sure that something like this was working the way i
thought it could work, I tried all this in a small test-class where it
worked perfectly well. However, in my real application I get the
compiler error telling me that
"error: expected `)' before '*' token" together with
"error: ISO C++ forbids declaration of 'FrameWork' with no
type" and later on
"error: 'FrameWork' has not been declared"

so I guess it should only be a minor problem here. I checked the
inlcudes and they should be fine...

OK, here are the classes which work:

Base-Class:
#ifndef _test_
#define _test_

#include <iostream>

class Test {
public:
virtual void first() =0;
void second() {
std::cout << "second Method\n";
}
};
#endif

Child-Class:
#ifndef _test_child_
#define _test_child_

#include "test.cpp"
class Test_child : public Test {
public:
void first() {
std::cout << "first\n";
}
};
#endif

The class usig the base-class in a method parameter:
#include "test.cpp"
#include "test_child.cpp"
#include <iostream>

class Using{
public:
void use(Test* tmp) {
void used(Test & tmp) { // More like that in C++ ...
std::cout << "call from using..";
tmp->first();
tmp.first();
}
};

int main (int argc, char * const argv[]) {
Test_child tst;
Using u;
u.use(&tst);
u.use(tst);
}

--------------------------------------------------------------------------
Now let's come to my problem-children of today:

Base-Class-Header:
#ifndef _FrameWork_
#define _FrameWork_

#include <iostream>
#include <fstream>

class FrameWork{
public:
void init();

Note: this function is *not* virtual, nor inline, thus you will need to
compile framework.cpp
Thanks for the hint. It is pretty obvious now that you say it ;)
>
virtual void output(int type, std::string) = 0;
private:
ModelContainer* models;
};
#endif /*_FrameWork_*/

Base-Class-Cpp:
#include "FrameWork.h"

void FrameWork::init() {
models = new ModelContainer(this);
std::cout << "initializing";
}

////////////////////////////////////////////

Child-Class-Header:
#ifndef _FrameWork_GUI_
#define _FrameWork_GUI_

#include "FrameWork.h"

It is bad practice to put upper-case in include names as it tend to
change when you go from one system to another ... (just a
recommendation, I recently had another case-hell because of that ...)
Thanks a lot, I will change all headers... I did not know it could lead
to problems..

class FrameWork_GUI : public FrameWork{
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

Child-Class-Cpp:
#include "FrameWork_GUI.h"

void FrameWork_GUI::output(int type, std::string str) {
std::cout << str;
}
// OK, the class ModelContainer is waiting for a FrameWork-Object in
its Constructor.
// The errors I get during compiling relate to this class exactly there
where I use the FrameWork-object
// and tell me that FrameWork would not be defined.

Usage-Class-Header (ModelContainer):

class FrameWork;
What does this mean? Do I have to add this line somewhere in the class
"ModelContainer.h"? If yes, then why?
>
class ModelContainer {
public:
ModelContainer(FrameWork* crd2);
private:
FrameWork* crd;
};
Usage-Class-Cpp:

#include "FrameWork.h"
This is in the original file, I just made a copy-and-paste error. It is
in all files which use it!
>
ModelContainer::ModelContainer(FrameWork* crd2) {
crd=crd2;
}

OK, last thing here would be the relevant part of my Makefile. Do I
need the FrameWork.o in there as well? I was not sure because it was
abstract.. However, if I put it in there or not.. I get the same
errors..

Yes, you need FrameWork.o as not all the methods are pure virtual ...
OK, I changed the Makefile to include FrameWork.o, the includes are in
all the Files using the FrameWork-class and I still get the errors
telling me that " ISO C++ forbids declaration of 'FrameWork' with
no type"

What does the line
class FrameWork;
mean? Where and why should I put it?

Thanks a lot once more,...
Tim

Aug 15 '06 #3
silversurfer2025 wrote:
Pierre Barbier de Reuille wrote:
>silversurfer2025 wrote:
>>Hello everyone,
[...]
>>>
Usage-Class-Header (ModelContainer):
class FrameWork;
What does this mean? Do I have to add this line somewhere in the class
"ModelContainer.h"? If yes, then why?
Yes, you need to put it in ModelContainer.h *before* the definition of
the class ModelContainer.
This statement simply tells the compiler that a class named FrameWork
does exists somewhere in that namespace, but you don't want to give him
the complete definition right now (it is called forward declaration). If
what you need of a class is only a pointer or reference, that's all you
need to make your code work.
>
>>class ModelContainer {
public:
ModelContainer(FrameWork* crd2);
private:
FrameWork* crd;
};
Usage-Class-Cpp:
#include "FrameWork.h"
This is in the original file, I just made a copy-and-paste error. It is
in all files which use it!
>>ModelContainer::ModelContainer(FrameWork* crd2) {
crd=crd2;
}

OK, last thing here would be the relevant part of my Makefile. Do I
need the FrameWork.o in there as well? I was not sure because it was
abstract.. However, if I put it in there or not.. I get the same
errors..
Yes, you need FrameWork.o as not all the methods are pure virtual ...

OK, I changed the Makefile to include FrameWork.o, the includes are in
all the Files using the FrameWork-class and I still get the errors
telling me that " ISO C++ forbids declaration of 'FrameWork' with
no type"

What does the line
class FrameWork;
mean? Where and why should I put it?

Thanks a lot once more,...
Tim
Aug 15 '06 #4
Yes, you need to put it in ModelContainer.h *before* the definition of
the class ModelContainer.
This statement simply tells the compiler that a class named FrameWork
does exists somewhere in that namespace, but you don't want to give him
the complete definition right now (it is called forward declaration). If
what you need of a class is only a pointer or reference, that's all you
need to make your code work.
Wonderful, the error in most of the cases was the circle-include.
However, the first compiler error is not created by such a mistake...
If it is okay, I am giving the class declaration and definition once
more here:

------------------------------------------
FrameWork.h:
#ifndef _framework_
#define _framework_

#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include "FeatureVector.h"
#include "ModelContainer.h"
#include "FeatureExtraction.h"
#include "HebbConnections.h"
#include "ModelContainer.h"
#include "ImageHandler.h"
#include "./Fundamental/ConfigReader.h"
#include "./ImageProcessing/Formation/YUVImage.h"
#include "./Structures/TribotsException.h"
#include "iGRLVQ.h"
#include "PostProcessing.h"

class FrameWork {
public:
void init();
virtual void output(int type, std::string) = 0;

private:
HebbConnections* hebb;
ModelContainer* models;
ModelContainer* trainData;
ModelContainer* testData;
FeatureExtraction* extractor;

ImageHandler* ih;
FeatureVector* extracted;
YUVImage* currentImage;
iGRLVQ* learner;

std::map<int, std::stringindexImageMap;
};

#endif /*_FrameWork_*/
------------------------------------------
FrameWork.cpp:
#include "FrameWork.h"

void FrameWork::init() {
extractor = new FeatureExtraction(this);
hebb = new HebbConnections(this);
models = new ModelContainer(this);
trainData = new ModelContainer(this);
testData = new ModelContainer(this);
ih = new ImageHandler(this);
learner = new iGRLVQ(this,models,NULL);
}
------------------------------------------
FrameWorkGUI.h:
#ifndef _framework_gui_
#define _framework_gui_

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

class FrameWork_GUI : public FrameWork {
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

------------------------------------------
FrameWorkGUI.cpp:
#include "FrameWork_GUI.h"

void FrameWork_GUI::output(int type, std::string str) {
std::cout << "test";
}

Unfortunately the compiler error is still
FrameWork_GUI.h:12: error: expected class-name before '{' token

So why the heck is the FrameWorkGU not finding FrameWork?

Thanks, I honestly would have not thought of forward declaration...
well seems I am quite a beginner ;)

Tim

Aug 15 '06 #5
silversurfer2025 wrote:
>Yes, you need to put it in ModelContainer.h *before* the definition
of the class ModelContainer.
This statement simply tells the compiler that a class named FrameWork
does exists somewhere in that namespace, but you don't want to give
him the complete definition right now (it is called forward
declaration). If what you need of a class is only a pointer or
reference, that's all you need to make your code work.

Wonderful, the error in most of the cases was the circle-include.
However, the first compiler error is not created by such a mistake...
If it is okay, I am giving the class declaration and definition once
more here:

------------------------------------------
FrameWork.h:
#ifndef _framework_
#define _framework_
First off, names that begin with an underscore in the global namespace
(and that includes macro names) are reserved by the implementation, so
drop the leading underscores here and invent some more meaningful name,
like 'FrameWork_h_included'. Make sure the spelling is the same every
time you're using it.
>
#include <string>
#include <map>
OK.
#include <iostream>
#include <fstream>
I don't see anything from those two headers used here. Why do you think
you need to include them?
#include "FeatureVector.h"
#include "ModelContainer.h"
#include "FeatureExtraction.h"
#include "HebbConnections.h"
#include "ModelContainer.h"
#include "ImageHandler.h"
#include "./Fundamental/ConfigReader.h"
#include "./ImageProcessing/Formation/YUVImage.h"
#include "./Structures/TribotsException.h"
#include "iGRLVQ.h"
#include "PostProcessing.h"
I don't think you really need these here. If your class only has
declarations of pointers to those types, you're much better off
forward-declaring them all instead of including their respective
headers.
>
class FrameWork {
public:
void init();
virtual void output(int type, std::string) = 0;
Passing objects is better by reference to const...
>
private:
HebbConnections* hebb;
ModelContainer* models;
ModelContainer* trainData;
ModelContainer* testData;
FeatureExtraction* extractor;

ImageHandler* ih;
FeatureVector* extracted;
YUVImage* currentImage;
iGRLVQ* learner;
As it turns out below, you're managing your own dynamic memory.
Read up on "The Rule of Three" and follow it.

Also, if your class is intended to be deleted polymorphically, you
should think of making the destructor virtual.
>
std::map<int, std::stringindexImageMap;
};

#endif /*_FrameWork_*/
The comment doesn't match the symbol name. Beware.
------------------------------------------
FrameWork.cpp:
#include "FrameWork.h"
Here you might actually need to include all headers because you
are initialising those objects here and the compiler needs to know
the definition of the classes.
>
void FrameWork::init() {
extractor = new FeatureExtraction(this);
hebb = new HebbConnections(this);
models = new ModelContainer(this);
trainData = new ModelContainer(this);
testData = new ModelContainer(this);
ih = new ImageHandler(this);
learner = new iGRLVQ(this,models,NULL);
}
------------------------------------------
FrameWorkGUI.h:
#ifndef _framework_gui_
#define _framework_gui_
Again, same message about the leading underscore and a more meaningful
name, like "FrameWorkGUI_h_included".
>
#include <iostream>
You don't seem to be using anything defined in that header, why include
it at all?
#include "FrameWork.h"

class FrameWork_GUI : public FrameWork {
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

------------------------------------------
FrameWorkGUI.cpp:
#include "FrameWork_GUI.h"
The name of this header does NOT match the name you just wrote above
when showing the contents of the file. This one has an extra '_' in
it. Make sure you're including the right file. Clean up your project
by throwing away what is not needed.
>
void FrameWork_GUI::output(int type, std::string str) {
std::cout << "test";
Now, *here* you're using 'std::cout', but this file does not include
the <iostream(by itself). It should. You should *not* rely on your
headers including other headers. All necessary headers must be here
in the same source file, so we can easily understand what is used and
where.
}

Unfortunately the compiler error is still
FrameWork_GUI.h:12: error: expected class-name before '{' token

So why the heck is the FrameWorkGU not finding FrameWork?

Thanks, I honestly would have not thought of forward declaration...
well seems I am quite a beginner ;)
I don't see any forward-declarations in your code you posted here.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 15 '06 #6

"silversurfer2025" <ki****@web.dewrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>Yes, you need to put it in ModelContainer.h *before* the definition of
the class ModelContainer.
This statement simply tells the compiler that a class named FrameWork
does exists somewhere in that namespace, but you don't want to give him
the complete definition right now (it is called forward declaration). If
what you need of a class is only a pointer or reference, that's all you
need to make your code work.

Wonderful, the error in most of the cases was the circle-include.
However, the first compiler error is not created by such a mistake...
If it is okay, I am giving the class declaration and definition once
more here:

------------------------------------------
FrameWork.h:
#ifndef _framework_
#define _framework_
I'm not positive, but I seem to recall that you shouldn't have leading or
tailing underscores in your include guards. (Someone else can cite chapter
and verse from the Standard, I'm sure.)
>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include "FeatureVector.h"
#include "ModelContainer.h"
#include "FeatureExtraction.h"
#include "HebbConnections.h"
#include "ModelContainer.h"
#include "ImageHandler.h"
#include "./Fundamental/ConfigReader.h"
#include "./ImageProcessing/Formation/YUVImage.h"
#include "./Structures/TribotsException.h"
#include "iGRLVQ.h"
#include "PostProcessing.h"
Since you're using pointers to most of the types in the files above, you
might want to consider just forward-declaring the types here, and putting
the #include statements in the .cpp file instead. It's cleaner that way,
and you have fewer dependencies when including this header in other files.
(Besides, this is what led to your circular-inclusion problems in the first
place, right? :-))
class FrameWork {
public:
void init();
virtual void output(int type, std::string) = 0;

private:
HebbConnections* hebb;
ModelContainer* models;
ModelContainer* trainData;
ModelContainer* testData;
FeatureExtraction* extractor;

ImageHandler* ih;
FeatureVector* extracted;
YUVImage* currentImage;
iGRLVQ* learner;

std::map<int, std::stringindexImageMap;
};

#endif /*_FrameWork_*/
------------------------------------------
FrameWork.cpp:
#include "FrameWork.h"

void FrameWork::init() {
extractor = new FeatureExtraction(this);
hebb = new HebbConnections(this);
models = new ModelContainer(this);
trainData = new ModelContainer(this);
testData = new ModelContainer(this);
ih = new ImageHandler(this);
learner = new iGRLVQ(this,models,NULL);
}
------------------------------------------
FrameWorkGUI.h:
Is that name correct? You're including "FrameWork_GUI.h". Do you have two
versions in your project directory?
#ifndef _framework_gui_
#define _framework_gui_

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

class FrameWork_GUI : public FrameWork {
Is this line 12, where the error is reported?
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

------------------------------------------
FrameWorkGUI.cpp:
#include "FrameWork_GUI.h"

void FrameWork_GUI::output(int type, std::string str) {
std::cout << "test";
}

Unfortunately the compiler error is still
FrameWork_GUI.h:12: error: expected class-name before '{' token
What's line 12?
>
So why the heck is the FrameWorkGU not finding FrameWork?
Are there other errors? Someimes, if there is an error in compiling a
header, then errors are reported in units which include that header, and
those errors may be reported first (oddly enough).

Also, you might try cleaning and re-building the whole project, to be sure
the compiler is seeing the latest information. (Just a thought. VC++, at
least, seems to get screwed up sometimes when changing headers.)

-Howard
Aug 15 '06 #7
First of all, thanks everybody, specially Howard and Victor for
helping. i am honestly very happy to have your suggestions and hints on
better coding, I am happy I can learn a lot this way!

Howard, wrote:
"silversurfer2025" <ki****@web.dewrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Yes, you need to put it in ModelContainer.h *before* the definition of
the class ModelContainer.
This statement simply tells the compiler that a class named FrameWork
does exists somewhere in that namespace, but you don't want to give him
the complete definition right now (it is called forward declaration). If
what you need of a class is only a pointer or reference, that's all you
need to make your code work.
Wonderful, the error in most of the cases was the circle-include.
However, the first compiler error is not created by such a mistake...
If it is okay, I am giving the class declaration and definition once
more here:

------------------------------------------
FrameWork.h:
#ifndef _framework_
#define _framework_

I'm not positive, but I seem to recall that you shouldn't have leading or
tailing underscores in your include guards. (Someone else can cite chapter
and verse from the Standard, I'm sure.)
It will be changed... I took this habit from some other code and
thought it was standard,...

>

#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include "FeatureVector.h"
#include "ModelContainer.h"
#include "FeatureExtraction.h"
#include "HebbConnections.h"
#include "ModelContainer.h"
#include "ImageHandler.h"
#include "./Fundamental/ConfigReader.h"
#include "./ImageProcessing/Formation/YUVImage.h"
#include "./Structures/TribotsException.h"
#include "iGRLVQ.h"
#include "PostProcessing.h"

Since you're using pointers to most of the types in the files above, you
might want to consider just forward-declaring the types here, and putting
the #include statements in the .cpp file instead. It's cleaner that way,
and you have fewer dependencies when including this header in other files.
(Besides, this is what led to your circular-inclusion problems in the first
place, right? :-))
Yes, you are right :( It will as well be changed... But at least the
error does not seem to come from here..

>
class FrameWork {
public:
void init();
virtual void output(int type, std::string) = 0;

private:
HebbConnections* hebb;
ModelContainer* models;
ModelContainer* trainData;
ModelContainer* testData;
FeatureExtraction* extractor;

ImageHandler* ih;
FeatureVector* extracted;
YUVImage* currentImage;
iGRLVQ* learner;

std::map<int, std::stringindexImageMap;
};

#endif /*_FrameWork_*/
------------------------------------------
FrameWork.cpp:
#include "FrameWork.h"

void FrameWork::init() {
extractor = new FeatureExtraction(this);
hebb = new HebbConnections(this);
models = new ModelContainer(this);
trainData = new ModelContainer(this);
testData = new ModelContainer(this);
ih = new ImageHandler(this);
learner = new iGRLVQ(this,models,NULL);
}
------------------------------------------
FrameWorkGUI.h:

Is that name correct? You're including "FrameWork_GUI.h". Do you have two
versions in your project directory?
Sorry, it is a typo. The file is named FrameWork_GUI.h and so is the
include...

>
#ifndef _framework_gui_
#define _framework_gui_

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

class FrameWork_GUI : public FrameWork {

Is this line 12, where the error is reported?
Yes, the erroneous line is the one class FrameWork_GUI... (the first
usage of FrameWork in this file)

>
void output(int type, std::string);
};

#endif /*_FrameWork_GUI_*/

------------------------------------------
FrameWorkGUI.cpp:
#include "FrameWork_GUI.h"

void FrameWork_GUI::output(int type, std::string str) {
std::cout << "test";
}

Unfortunately the compiler error is still
FrameWork_GUI.h:12: error: expected class-name before '{' token

What's line 12?
class FrameWork_GUI : public FrameWork {

>

So why the heck is the FrameWorkGU not finding FrameWork?

Are there other errors? Someimes, if there is an error in compiling a
header, then errors are reported in units which include that header, and
those errors may be reported first (oddly enough).
There is no other error... This is (currently) the only one ;)
>
Also, you might try cleaning and re-building the whole project, to be sure
the compiler is seeing the latest information. (Just a thought. VC++, at
least, seems to get screwed up sometimes when changing headers.)
I did, and it did not help.
>

Thanks once more..
Tim

Aug 15 '06 #8
silversurfer2025 wrote:
[..]
Howard, wrote:
>"silversurfer2025" <ki****@web.dewrote in message
news:11*********************@b28g2000cwb.googlegr oups.com...
>>[..]
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include "FeatureVector.h"
#include "ModelContainer.h"
#include "FeatureExtraction.h"
#include "HebbConnections.h"
#include "ModelContainer.h"
#include "ImageHandler.h"
#include "./Fundamental/ConfigReader.h"
#include "./ImageProcessing/Formation/YUVImage.h"
#include "./Structures/TribotsException.h"
#include "iGRLVQ.h"
#include "PostProcessing.h"

Since you're using pointers to most of the types in the files above,
you might want to consider just forward-declaring the types here,
and putting the #include statements in the .cpp file instead. It's
cleaner that way, and you have fewer dependencies when including
this header in other files. (Besides, this is what led to your
circular-inclusion problems in the first place, right? :-))

Yes, you are right :( It will as well be changed... But at least the
error does not seem to come from here..
My *guess* would be that it does. Imagine that in one of those files
you (mistakenly, of course) left the same macro used in #ifndef as in
the "FrameWork.h" file. What would happen? Who knows? With so many
headers apparently including each other for no particular reason, and
applying double inclusion guards possibly at the wrong time, anything
can happen.

Drop all unnecessary includes, or start fresh, and only use forward
declarations. Only include when you really need to (like in the case
with deriving from FrameWork, you do need to give the class FrameWork
definition to the compiler). You will eventually create a network of
classes light enough to be manageable.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 15 '06 #9

Victor Bazarov wrote:
silversurfer2025 wrote:
[..]
Howard, wrote:
"silversurfer2025" <ki****@web.dewrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
[..]
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include "FeatureVector.h"
#include "ModelContainer.h"
#include "FeatureExtraction.h"
#include "HebbConnections.h"
#include "ModelContainer.h"
#include "ImageHandler.h"
#include "./Fundamental/ConfigReader.h"
#include "./ImageProcessing/Formation/YUVImage.h"
#include "./Structures/TribotsException.h"
#include "iGRLVQ.h"
#include "PostProcessing.h"
Since you're using pointers to most of the types in the files above,
you might want to consider just forward-declaring the types here,
and putting the #include statements in the .cpp file instead. It's
cleaner that way, and you have fewer dependencies when including
this header in other files. (Besides, this is what led to your
circular-inclusion problems in the first place, right? :-))
Yes, you are right :( It will as well be changed... But at least the
error does not seem to come from here..

My *guess* would be that it does. Imagine that in one of those files
you (mistakenly, of course) left the same macro used in #ifndef as in
the "FrameWork.h" file. What would happen? Who knows? With so many
headers apparently including each other for no particular reason, and
applying double inclusion guards possibly at the wrong time, anything
can happen.
Oh Victor, you are so right... Naturally it was another circle-include
I put in there for testing reasons and forgot to delete...
>
Drop all unnecessary includes, or start fresh, and only use forward
declarations. Only include when you really need to (like in the case
with deriving from FrameWork, you do need to give the class FrameWork
definition to the compiler). You will eventually create a network of
classes light enough to be manageable.
I will work over the files once more managing the include files and
putting them into the right place.I started putting all needed includes
into the header file because I read in a tutorial that this was good
programming practice because all includes would be in the same place..
I seem to read the wrong sources don't I?

Seems to be solved right now, thanks a lot once more and greetings from
rainy Germany
Tim
>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 15 '06 #10

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

Similar topics

7
by: Rob Long | last post by:
Hey I've noticed a somewhat annoying feature in PHP5 when it comes to extended classes and types. If I declare an interface and a class that implements it, I get a "compile" error (read parse...
1
by: Mark | last post by:
I have class1 and class2. When I inherit from class1 or class2, I want to have to implement a method called MyMethod(). If this was my only requirement, I'd make MyMethod and abstract method in...
1
by: Dave Veeneman | last post by:
I'm creating several forms that inherit from a base form. I want to require the derived forms to implement certain methods of the base form. The easy solution would be to declare abstract methods...
2
by: Rachel Suddeth | last post by:
I have a base form (Windows.Forms) that really should be abstract. There are certain methods that must be overridden. However, if I make it abstract, I can not get designer support. (VS tells me "...
3
by: Adam Clauss | last post by:
I am developing an abstract class which implements IEnumerable<T>. I need the actual implemented methods here to be abstract as well - they will be implemented by MY subclasses. However, I...
7
by: tron.thomas | last post by:
Please consider the following code: class Abstract { public: virtual ~Abstract() {} virtual void Method() = 0; }; class Concrete : public virtual Abstract
4
by: Gert Kok | last post by:
The microsoft page http://msdn2.microsoft.com/en-us/library/9fkccyh4.aspx states: Remarks (nr 4) Virtual properties behave like abstract methods, except for the differences in declaration...
3
by: Lord0 | last post by:
I am trying to implement variable content containers using an abstract type and type substitution. My schema is as follows: <?xml version="1.0" encoding="UTF-8"?> <schema...
1
by: =?ISO-8859-2?Q?Gordan_Kre=B9i=E6?= | last post by:
I have classic interface/implementation paradigm. That does not work with stl containers :) Call to doAbstract(derivedList) yelds compilation error: sample.cpp: In function 'int main(int,...
4
by: Tim Frink | last post by:
Hi, I'm looking for any references about Abstract Interpretation applied to the language C. More precisely, I'm interested in the abstract domain for C, i.e. how the full set of C operations...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.