C ++菜鸟有麻烦。有人想帮忙吗? [英] C++ rookie having trouble. Anybody care to try to help?

查看:96
本文介绍了C ++菜鸟有麻烦。有人想帮忙吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有个傻瓜。我想,对于有C ++经验的人来说,这个

对于单词来说太可悲了。对于一个新手来说,使用这个项目作为一种期中考试的
。在他自学成才的如何用C ++编程中当然,

它似乎是一个不可逾越的问题。有人可以帮忙吗?我在这里结束了。

。一切*看起来*(对这个新秀来说,无论如何)是正确的,

但编译器正在对它进行抨击。


这里是Bar的类声明

班级酒吧

{

私人:

int完成;

char文件[254];

浮动PartDone;

int时间;

char SaveTo [254];

int DRate ;

int URate;

int行动;


公开:

Bar();

~Bar();

void完成(无效);

void失败(无效);

void错误(char * ErrorMsg);

void显示(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);

};


这里是声明例程Foo的头文件:


int Foo(char ** args,

void(* FileFunc)(char *,int,char *,char *),

void(* StatusFunc)(float,int,int,int,int),

void( * FinishFunc)(无效),

void(* ErrorFunc)(char *),

int * DoneFlag,

int Cols,

void(* PathFunc)(char *)

);


最后,这里是Foo被调用的地方/方式:


void Bar :: DoIt(char ** argv)


{

Foo(argv,

(void(*)(char *,int,char *,char *))this-> ChooseFile,< --- 1

(void(*) (float,int,int,int,int))this->显示,< --- 2

(void(*)(void))this->已完成,< ;- - 3

(void(*)(char *))this->错误,< --- 4

& this->完成,

80,

(void(*)(char *))this-> NewPath< --- 5

);

if(!this-> Done)

this-> Failed();

}


int main( int argc,char ** argv)


{

//我只是简单地不关心argc,所以关闭它,编译器!

#pragma unused(argc)


Bar FooBar;


FooBar.DoIt(argv);

}


在右边缘标有< ---#的行。指示

编译器barfs在哪里。针对每个#报告的特定错误。是:


1:

错误:从''void''非法显式转换为''void(*)(char *,

int,char *,char *)''

Baz.c ++ line 268(void(*)(char *,int,char *,char *))

this-> ChooseFile,


2:

错误:从''void''非法显式转换为''void(*)( float,

int,int,int,int)''

Baz.c ++ line 269(void(*)(float,int,int,int,int)) this->显示,


3:

错误:从''void''非法显式转换为''void(*)()''

BTDownloadHeadless.c ++第270行(void(*)(void))this->已完成,


4:

错误:从''void''非法显式转换为''void(*)(char *)''

Baz.c ++第271行(void(*)(char *))this-> ;错误,


5:

错误:从''void''非法显式转换为''void(*) (char *)''

Baz.c ++ line 274(void(*)(char *))this-> NewPath


可以看出,在所有情况下,它们基本上都是同样的错误,对于正在发生的确切演员而言,

变化。


那么,恰恰相反,我做错了吗?我能找到的所有东西

K& RC,2nd或Stroustrup C ++ 3rd告诉我这个*应该是* b
$ b完全合法的代码(尽管我自由地批准它可能是* CRAPPY *

代码,风格明智...那是一个完全不同的主题...)但是对于一些

的原因,我得到了阻止我进入轨道的编译器barf。

列出的5个错误是代码中的唯一错误(至少为编译器报告到这一点时的
) ) - 除了包含main()和DoIt()的

文件之外的所有其他内容都没有投诉。


有人给我一些建议吗?我做错了什么,怎么/为什么

是不是错了?


-

Don Bruder - da****@sonic.net < ---首选电子邮件 - SpamAssassinated。

讨厌垃圾邮件?见< http://www.spamassassin.org>对于一些非常好的信息。

我会选择一条清晰的道路:我会选择自由意志! - N. Peart

飞行陷阱信息页面:< http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>

解决方案

Don Bruder写道:

[SNIP]

(void(*)(char *,int,char *,char * ))this-> ChooseFile,


据我所知,你需要获取该函数的地址。但是

你不能。它是对成员函数的调用。它没有地址

可转换为正常的C风格的函数指针由于

那么,究竟是什么,我做错了?我能找到的所有东西都是K& RC,


K& RC没有课程和成员函数,所以我怀疑它包含

像上面这样的东西。

2nd,或者Stroustrup C ++ 3rd告诉我这个*应该是完全合法的代码




我也非常怀疑Stroustrup会说你可以将一个

成员函数(指针)转换成普通的C风格函数指针。


请,如果你真的想了解这个函数指针的东西,请阅读

来自Herb Sutter的优秀文章:

http://www.cuj.com/documents/s=8464/cujcexp0308sutter/


它描述了一个新标准库元素的候选者,一个可以用来传递任何函数的
,无论是成员还是不成员。现有的

实现你可以找到

http://www.boost.org


-

WW aka Attila



" Don Bruder" <哒**** @ sonic.net>在留言中写道

新闻:0Y ******************** @ typhoon.sonic.net ...

这里有一个难得的人。我想,对于一个有C ++经验的人来说,这对于单词来说太可悲了。对于一个新秀来说,使用这个项目作为期中考试的一种方式。在他自学成才的如何用C ++编程中当然,这似乎是一个不可逾越的问题。有人可以帮忙吗?我在这里结束了。一切*看起来*(对这个菜鸟来说,无论如何)是正确的,
但是编译器正在对它进行抨击。

这里是Bar的课堂声明
class Bar int完成;
char文件[254];
浮动PartDone;
int时间;
char SaveTo [254];
int DRate;
int URate;
int Action;

public:
Bar();
~Bar();
void完成(void);
void失败(void);
void错误(char * ErrorMsg);
void显示(浮点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);
};

这里是声明例程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 *)
);

最后,这里是Foo被调用的地方/方式:

void Bar :: DoIt(char ** argv)

{
Foo(argv,
(void(*)(char *,int,char *,char *))this-> ChooseFile,< --- 1
(void(*)(float, int,int,int,int))this->显示,< --- 2
(void(*)(void))this->完成,< --- 3
(void(*)(char *))this->错误,< --- 4
& this->完成,
80,
(void(*)( char *))this-> NewPath< --- 5

if(!this-> Done)
this-> Failed();
}

in t main(int argc,char ** argv)

//
//我只是简单地不关心argc,所以关闭它,编译器!
# pragma unused(argc)

Bar FooBar;

FooBar.DoIt(argv);
}

右边缘标有的行用< ---#指示
编译器barfs在哪里。针对每个#报告的特定错误。是:

1:
错误:从''void''到''void(*)的非法显式转换(char *,
int,char *,char *) ''
Baz.c ++ line 268(void(*)(char *,int,char *,char *))
this-> ChooseFile,

2:<错误:非法显式转换从''void''到''void(*)(float,
int,int,int,int)''
Baz.c ++ line 269(void( *)(float,int,int,int,int))this->显示,

3:
错误:从''void''非法显式转换为''void( *)()''
BTDownloadHeadless.c ++第270行(void(*)(void))this->完成,

4:
错误:非法显式转换''void''到''void(*)(char *)''
Baz.c ++ line 271(void(*)(char *))this->错误,
5:
错误:从''void''非法显式转换为''void(*)(char *)''
Baz.c ++第274行(void(*)(char *))这个> NewPath

As可以看出,他们在所有情况下都是基本相同的错误,对于正在发生的确切演员而言,
变化。

那么,究竟是什么,我做错了? ??我能在K& RC,2nd或Stroustrup C ++ 3rd中找到的所有东西都告诉我这个*应该是*完全合法的代码(尽管我自由地认为它可能是* CRAPPY *
代码,风格明智...那是一个完全不同的主题......)但是出于一些原因,我正在使用编译器barf阻止我跟踪。
5列出的错误是代码中唯一的错误(至少就编译器报告到此为止) - 除了包含main()和DoIt()的
文件之外的所有其他内容都没有投诉。

有人给我一些建议吗?我做错了什么,怎么/为什么
错了?




给出错误的行看起来很可疑。

AFAIK,指向成员函数的指针和指向

a非成员函数的指针不是''兼容'',并且有

没有明确的方法可以从一个转换为另一个。


你想要做什么?


你试过使用过载或虚拟功能

做'调度''看起来你想要做什么?


-Mike


你的问题是成员函数有一个隐含的参数

- this指针,因此它们的真实指针签名 - 和类型

取决于他们所在的班级。


换句话说,功能


int f1(int a);

int A :: f2(int a);

int B :: f3(int a);


实际上有很多不同的签名,不能互换使用,

即只有第一个有int(*)(int)类型,而第二个

的类型为int(A :: *)(int)等。


希望,这有助于

~阿列克谢


" Don Bruder" <哒**** @ sonic.net>在留言中写道

新闻:0Y ******************** @ typhoon.sonic.net ...

这里有一个难得的人。我想,对于一个有C ++经验的人来说,这对于单词来说太可悲了。对于一个新秀来说,使用这个项目作为期中考试的一种方式。在他自学成才的如何用C ++编程中当然,这似乎是一个不可逾越的问题。有人可以帮忙吗?我在这里结束了。一切*看起来*(对这个菜鸟来说,无论如何)是正确的,
但是编译器正在对它进行抨击。

这里是Bar的课堂声明
class Bar int完成;
char文件[254];
浮动PartDone;
int时间;
char SaveTo [254];
int DRate;
int URate;
int Action;

public:
Bar();
~Bar();
void完成(void);
void失败(void);
void错误(char * ErrorMsg);
void显示(浮点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);
};

这里是声明例程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 *)
);

最后,这里是Foo被调用的地方/方式:

void Bar :: DoIt(char ** argv)

{
Foo(argv,
(void(*)(char *,int,char *,char *))this-> ChooseFile,< --- 1
(void(*)(float, int,int,int,int))this->显示,< --- 2
(void(*)(void))this->完成,< --- 3
(void(*)(char *))this->错误,< --- 4
& this->完成,
80,
(void(*)( char *))this-> NewPath< --- 5

if(!this-> Done)
this-> Failed();
}

in t main(int argc,char ** argv)

//
//我只是简单地不关心argc,所以关闭它,编译器!
# pragma unused(argc)

Bar FooBar;

FooBar.DoIt(argv);
}

右边缘标有的行用< ---#指示
编译器barfs在哪里。针对每个#报告的特定错误。是:

1:
错误:从''void''到''void(*)的非法显式转换(char *,
int,char *,char *) ''
Baz.c ++ line 268(void(*)(char *,int,char *,char *))
this-> ChooseFile,

2:<错误:非法显式转换从''void''到''void(*)(float,
int,int,int,int)''
Baz.c ++ line 269(void( *)(float,int,int,int,int))this->显示,

3:
错误:从''void''非法显式转换为''void( *)()''
BTDownloadHeadless.c ++第270行(void(*)(void))this->完成,

4:
错误:非法显式转换''void''到''void(*)(char *)''
Baz.c ++ line 271(void(*)(char *))this->错误,
5:
错误:从''void''非法显式转换为''void(*)(char *)''
Baz.c ++第274行(void(*)(char *))这个> NewPath

As可以看出,他们在所有情况下都是基本相同的错误,对于正在发生的确切演员而言,
变化。

那么,究竟是什么,我做错了? ??我能在K& RC,2nd或Stroustrup C ++ 3rd中找到的所有东西都告诉我这个*应该是*完全合法的代码(尽管我自由地认为它可能是* CRAPPY *
代码,风格明智...那是一个完全不同的主题......)但是出于一些原因,我正在使用编译器barf阻止我跟踪。
5列出的错误是代码中唯一的错误(至少就编译器报告到此为止) - 除了包含main()和DoIt()的
文件之外的所有其他内容都没有投诉。

有人给我一些建议吗?我做错了什么,以及如何/为什么这是错的?

-
Don Bruder - da **** @ sonic.net < ---首选电子邮件 - SpamAssassinated。
讨厌垃圾邮件?见< http://www.spamassassin.org>对于一些非常棒的
信息。我会选择一条明确的道路:我会选择自由意志! - N. Peart
飞行陷阱信息页面:



< http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>


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::DoIt(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?

--
Don Bruder - da****@sonic.net <--- Preferred Email - SpamAssassinated.
Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
I will choose a path that''s clear: I will choose Free Will! - N. Peart
Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>

解决方案

Don Bruder wrote:
[SNIP]

(void (*)(char *, int, char *, char *)) this->ChooseFile,
As far as I understand you need to take the address of that function. But
you cannot. It is a call to a member function. It has no address
convertable to a "normal" C-style function pointer due to the
So what, precisely, am I doing wrong??? Everything I can find in
either K&R C,
K&R C has no classes and member functions, so I doubt that it contains
anything like the above.
2nd, or Stroustrup C++ 3rd shows me that this *SHOULD
BE* perfectly legal code



I also very much doubt that Stroustrup would say that you can convert a
member function (pointer) into a normal C-style function pointer.

Please, if you really wish to learn about this function pointer things read
this excellent article from Herb Sutter:

http://www.cuj.com/documents/s=8464/cujcexp0308sutter/

It is describing a candidate for a new standard library element, one which
can be used to pass around any functions, be it member or not. The existing
implementation of it you can find at

http://www.boost.org

--
WW aka Attila



"Don Bruder" <da****@sonic.net> wrote in message
news:0Y********************@typhoon.sonic.net...

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::DoIt(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?



The lines giving the errors look quite suspicious to me.
AFAIK, a pointer to a member function and a pointer to
a nonmember function are not ''compatible'', and there''s
no defined way to convert from one to the other.

What on Earth are you trying to do?

Have you tried using overloaded or virtual functions
to do the ''dispatching'' it looks like you''re trying to do?

-Mike


Your problem is that member functions have an implicit argument
- the "this" pointer, and therefore their "true" signature - and type
depends on the class they are in.

In other words, functions

int f1( int a );
int A::f2( int a );
int B::f3( int a );

have, in fact quite different signatures and cannot be used interchangeably,
namely only the 1st one has a type of int (*) (int), while the second one
has a type of int (A::*) (int) etc.

Hope, this helps
~Alexei

"Don Bruder" <da****@sonic.net> wrote in message
news:0Y********************@typhoon.sonic.net...

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::DoIt(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?

--
Don Bruder - da****@sonic.net <--- Preferred Email - SpamAssassinated.
Hate SPAM? See <http://www.spamassassin.org> for some seriously great info. I will choose a path that''s clear: I will choose Free Will! - N. Peart
Fly trap info pages:


<http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>


这篇关于C ++菜鸟有麻烦。有人想帮忙吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆