|
From: Roger F. <ra...@ha...> - 2004-09-07 00:22:16
|
Aloha from Honolulu,
Thank You Per, once again you have made my life easier and increased
my knowledge. Still, I have this question: How did you know what the
complete error message said? All that comes up in my compiler messages
is "assuming" on the first line and "(a" on the 2nd. Yes that is an
open parentesis and a lower case a; and nothing else. I tried copying
the line and pasting it into a Notebook file and got the same result.
Where does one find these answers?
Thanks Again,
Roger
Per Westermark wrote:
>1) The complete error messages are:
>fnkptr.cpp:29: error: assuming pointer to member `void Dog::Speak() const'
>fnkptr.cpp:29: error: (a pointer to member can only be formed with `&Dog::Speak() const')
>
>Just add a & before eacn function name, just as the error message suggest,
>and the compiler will be happy.
>
>2) Notice that Dev-C++ is an integrated development environment, not a
>compiler. It is the gcc team - or possibly the MinGW team - that is
>responsible for which error messages are emitted by the compiler. By the
>way, 99.9% if the error messages I have seen have been quite obvious.
>
>3) windef.h is a file seldom directly included in a program. However, a
>number of other include files recursively requests the windef.h file. If
>you check again, you should be able to find out why the compiler mentioned
>it. The compiler never makes this kind of mistake. The only reason it said
>BOOL was already defined in windef.h was that the program directly or
>indirectly did include windef.h
>
>/Per W
>
>On Sun, 5 Sep 2004, Roger Furer wrote:
>
>
>
>>Aloha from Honolulu,
>> The following was taken from Sams Teach Yourself C++ and refuses to
>>compile. The compiler reports the error at the line following
>>"Dog::PlayDead" which is the closing brace and semi-colon for the "PDF
>>DogFunctions...". I have marked it with an exclamation point ! here.
>>While I do need to know what the code's problem is, more vexing is that
>>in the compiler report window under messages is listed "assuming" and on
>>the next line "(a". Nowhere have I been able to find a list of the
>>various messages. I looked under the Help window of the program
>>(Version 4.9.8.0) and also on the Bloodshed site, but no luck there
>>either. I would suggest that a comprehensive list of error messages
>>would benefit most everyone using these programs.
>> A further note: earlier in the lesson was a line: enum BOOL {FALSE,
>>TRUE}; that generated the folowing error messages: "conflicting" and
>>then: (copied from the compiler report window)
>>227 C:\Dev-Cpp\include\windef.h previous declaration as `typedef
>>WINBOOL BOOL'
>> My solution was to comment it out, but why did the message appear
>>when windef.h was never included in the code?
>>Thanks in advance,
>>Mahalo,
>>Roger
>>
>>
>>//Listing 20.10 Array of pointers to member functions
>>#include <iostream>
>>class Dog
>>{
>> public:
>> void Speak()const { std::cout << "Woof!\n"; }
>> void Move() const { std::cout << "Walking to heel...\n"; }
>> void Eat() const { std::cout << "Gobbling food...\n"; }
>> void Growl() const { std::cout << "Grrrrr\n"; }
>> void Whimper() const { std::cout << "Whining noises...\n"; }
>> void RollOver() const { std::cout << "Rolling over...\n"; }
>> void PlayDead() const
>> { std::cout << "Is this the end of Little Caeser?\n"; }
>>};
>>
>>typedef void (Dog::*PDF)()const ;
>>
>>int main()
>>{
>> const int MaxFuncs = 7;
>> PDF DogFunctions[MaxFuncs] =
>> { Dog::Speak,
>> Dog::Move,
>> Dog::Eat,
>> Dog::Growl,
>> Dog::Whimper,
>> Dog::RollOver,
>> Dog::PlayDead
>>! };
>> Dog* pDog =0;
>> int Method;
>> bool fQuit = false;
>> while (!fQuit)
>> {
>> std::cout << "(0)Quit (1)Speak (2)Move (3)Eat (4)Growl";
>> std::cout << " (5)Whimper (6)Roll Over (7)Play Dead: ";
>> std::cin >> Method;
>> if (Method == 0)
>> {
>> fQuit = true;
>> break;
>> }
>> else
>> {
>> pDog = new Dog;
>> (pDog->*DogFunctions[Method-1])();
>> delete pDog;
>> }
>> }
>> return 0;
>>}
>>
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by BEA Weblogic Workshop
>>FREE Java Enterprise J2EE developer tools!
>>Get your free copy of BEA WebLogic Workshop 8.1 today.
>>http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>>
>>
>
>
>
>
|