D
Don Bruder
Got a stumper here. I imagine that for someone experienced in C++, this
is too pathetic for words. For a rookie, using this project as a sort
of "midterm exam" in his self-taught "how to program in C++" course,
it's seeming to be an insurmountable problem. Can anyone assist? I'm at
wit's end here. Everything *LOOKS* (to this rookie, anyway) correct,
but the compiler is barfing on it.
Here's the class declaration for Bar
class Bar
{
private:
int Done;
char File[254];
float PartDone;
int Time;
char SaveTo[254];
int DRate;
int URate;
int Action;
public:
Bar();
~Bar();
void Finished(void);
void Failed(void);
void Error(char *ErrorMsg);
void Display(float PercentDone, int Time, int DRate,
int URate, int Action);
void ChooseFile(char *DefaultName, int MaxFileNameSize,
char *SaveTo, char *Dir);
void NewPath(char *Path);
void DoIt(char **argv);
};
Here's the header file that declares routine Foo:
int Foo(char **args,
void (*FileFunc)(char *, int, char *, char *),
void (*StatusFunc)(float, int, int, int, int),
void (*FinishFunc)(void),
void (*ErrorFunc)(char *),
int *DoneFlag,
int Cols,
void (*PathFunc)(char *)
);
And finally, here's where/how Foo gets called:
void Bar:oIt(char **argv)
{
Foo(argv,
(void (*)(char *, int, char *, char *)) this->ChooseFile, <--- 1
(void (*)(float, int, int, int, int)) this->Display, <--- 2
(void (*)(void)) this->Finished, <--- 3
(void (*)(char *)) this->Error, <--- 4
&this->Done,
80,
(void (*)(char *)) this->NewPath <--- 5
);
if (!this->Done)
this->Failed();
}
int main(int argc, char **argv)
{
// I just plain don't care about argc, so shut up about it, compiler!
#pragma unused (argc)
Bar FooBar;
FooBar.DoIt(argv);
}
Lines marked on the right margin with "<--- #" indicate where the
compiler barfs at me. The specific errors reported for each "#" are:
1:
Error : illegal explicit conversion from 'void' to 'void (*)(char *,
int, char *, char *)'
Baz.c++ line 268 (void (*)(char *, int, char *, char *))
this->ChooseFile,
2:
Error : illegal explicit conversion from 'void' to 'void (*)(float,
int, int, int, int)'
Baz.c++ line 269 (void (*)(float, int, int, int, int)) this->Display,
3:
Error : illegal explicit conversion from 'void' to 'void (*)()'
BTDownloadHeadless.c++ line 270 (void (*)(void)) this->Finished,
4:
Error : illegal explicit conversion from 'void' to 'void (*)(char *)'
Baz.c++ line 271 (void (*)(char *)) this->Error,
5:
Error : illegal explicit conversion from 'void' to 'void (*)(char *)'
Baz.c++ line 274 (void (*)(char *)) this->NewPath
As can be seen, they're basicaly the same error in all cases, with
variations for the exact cast that's happening.
So what, precisely, am I doing wrong??? Everything I can find in either
K&R C, 2nd, or Stroustrup C++ 3rd shows me that this *SHOULD BE*
perfectly legal code (although I freely grant that it may be *CRAPPY*
code, style-wise... That's a whole different topic...) yet for some
reason, I'm getting compiler barfs that are stopping me in my tracks.
The 5 errors listed are the only ones anywhere in the code (at least as
far as the compiler reports to this point) - everything else except the
file containing main() and DoIt() compiles without complaint.
Anybody got some advice for me? What is it I'm doing wrong, and how/why
is it wrong?
is too pathetic for words. For a rookie, using this project as a sort
of "midterm exam" in his self-taught "how to program in C++" course,
it's seeming to be an insurmountable problem. Can anyone assist? I'm at
wit's end here. Everything *LOOKS* (to this rookie, anyway) correct,
but the compiler is barfing on it.
Here's the class declaration for Bar
class Bar
{
private:
int Done;
char File[254];
float PartDone;
int Time;
char SaveTo[254];
int DRate;
int URate;
int Action;
public:
Bar();
~Bar();
void Finished(void);
void Failed(void);
void Error(char *ErrorMsg);
void Display(float PercentDone, int Time, int DRate,
int URate, int Action);
void ChooseFile(char *DefaultName, int MaxFileNameSize,
char *SaveTo, char *Dir);
void NewPath(char *Path);
void DoIt(char **argv);
};
Here's the header file that declares routine Foo:
int Foo(char **args,
void (*FileFunc)(char *, int, char *, char *),
void (*StatusFunc)(float, int, int, int, int),
void (*FinishFunc)(void),
void (*ErrorFunc)(char *),
int *DoneFlag,
int Cols,
void (*PathFunc)(char *)
);
And finally, here's where/how Foo gets called:
void Bar:oIt(char **argv)
{
Foo(argv,
(void (*)(char *, int, char *, char *)) this->ChooseFile, <--- 1
(void (*)(float, int, int, int, int)) this->Display, <--- 2
(void (*)(void)) this->Finished, <--- 3
(void (*)(char *)) this->Error, <--- 4
&this->Done,
80,
(void (*)(char *)) this->NewPath <--- 5
);
if (!this->Done)
this->Failed();
}
int main(int argc, char **argv)
{
// I just plain don't care about argc, so shut up about it, compiler!
#pragma unused (argc)
Bar FooBar;
FooBar.DoIt(argv);
}
Lines marked on the right margin with "<--- #" indicate where the
compiler barfs at me. The specific errors reported for each "#" are:
1:
Error : illegal explicit conversion from 'void' to 'void (*)(char *,
int, char *, char *)'
Baz.c++ line 268 (void (*)(char *, int, char *, char *))
this->ChooseFile,
2:
Error : illegal explicit conversion from 'void' to 'void (*)(float,
int, int, int, int)'
Baz.c++ line 269 (void (*)(float, int, int, int, int)) this->Display,
3:
Error : illegal explicit conversion from 'void' to 'void (*)()'
BTDownloadHeadless.c++ line 270 (void (*)(void)) this->Finished,
4:
Error : illegal explicit conversion from 'void' to 'void (*)(char *)'
Baz.c++ line 271 (void (*)(char *)) this->Error,
5:
Error : illegal explicit conversion from 'void' to 'void (*)(char *)'
Baz.c++ line 274 (void (*)(char *)) this->NewPath
As can be seen, they're basicaly the same error in all cases, with
variations for the exact cast that's happening.
So what, precisely, am I doing wrong??? Everything I can find in either
K&R C, 2nd, or Stroustrup C++ 3rd shows me that this *SHOULD BE*
perfectly legal code (although I freely grant that it may be *CRAPPY*
code, style-wise... That's a whole different topic...) yet for some
reason, I'm getting compiler barfs that are stopping me in my tracks.
The 5 errors listed are the only ones anywhere in the code (at least as
far as the compiler reports to this point) - everything else except the
file containing main() and DoIt() compiles without complaint.
Anybody got some advice for me? What is it I'm doing wrong, and how/why
is it wrong?