Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Error C2664: Cannot Convert Parameter 1 from 'x' to 'y'

Reply
Thread Tools

Re: Error C2664: Cannot Convert Parameter 1 from 'x' to 'y'

 
 
John Harrison
Guest
Posts: n/a
 
      06-25-2003

"Tim Mierzejewski" <(E-Mail Removed)> wrote in message
news:H%kKa.6098$(E-Mail Removed) igy.com...
> Could someone look through this code and tell me why I'm getting this

error?
> I'm only including the important code here. There's more obviously, but

this
> should be enough to solve the problem.
>
> #include "Creature.hpp" // This defines the class Creature.
> void Minotaur(Creature *Player);
>
> int CreatureSelection;
> cin >> CreatureSelection;
> Creature *Play1 = new Creature
> switch (CreatureSelection)
> {
> case (1):
> Minotaur(*Play1); // Line #33
> }
> return 0;
>
> void Minotaur(Creature *Player)
> {
> Player->SetValues(50, 20, 9, 4, false, 0, false, false, false, false,
> false) // Calls a function within Creature.hpp.
> }
>
>
> ----
> C:\......FileName.cpp(33): error C2664: 'Minotaur' : cannot convert
> parameter 1 from 'class Creature' to 'class Creature *'
> No user-defined-conversion operator available that can perform

this
> conversion, or the operator cannot be called
>


New to pointers?

Play1 is a pointer to a Creature, that makes *Play1 a Creature. Minotaur
needs a pointer to a Creature, but you've given it a Creature, that's what
the error message says. The answer in case you haven't worked it out already
is to drop the *.

Minotaur(Play1); // Line #33

john


 
Reply With Quote
 
 
 
 
Tim Mierzejewski
Guest
Posts: n/a
 
      06-25-2003
> New to pointers?
>
> Play1 is a pointer to a Creature, that makes *Play1 a Creature. Minotaur
> needs a pointer to a Creature, but you've given it a Creature, that's what
> the error message says. The answer in case you haven't worked it out

already
> is to drop the *.
>
> Minotaur(Play1); // Line #33




Yes, very new, and thanks to you, Suzanne, and Jack. You've made my life
that much better.

Tim M.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *' kaizen C++ 3 01-21-2006 08:07 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
Cannot convert to Ref parameter from C# to VB.Net Sanjay Tibrewal ASP .Net 2 08-04-2004 09:22 PM
Re: Error C2664: Cannot Convert Parameter 1 from 'x' to 'y' Jack Klein C++ 0 06-25-2003 05:39 PM
Re: Error C2664: Cannot Convert Parameter 1 from 'x' to 'y' Suzanne C++ 0 06-25-2003 05:38 PM



Advertisments