Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: Error C2664: Cannot Convert Parameter 1 from 'x' to 'y' (http://www.velocityreviews.com/forums/t267717-re-error-c2664-cannot-convert-parameter-1-from-x-to-y.html)

Suzanne 06-25-2003 05:38 PM

Re: Error C2664: Cannot Convert Parameter 1 from 'x' to 'y'
 
There's a type mismatch.

Play1 is of type Creature*. You pass it into function Minotaur() by
dereferencing it, creating a Creature. But function Minotaur() wants a
Creature*.

Change the call
Minotaur(*Play1)
to
Minotaur(Play1) // no dereferencing

-OR-
Change the function definition
void Minotaur(Creature* Player)
to
void Minotaur(Creature& Player) or // <--better; no copying required
void Minotaur(Creature Player)

I think.
Suzanne

Tim Mierzejewski wrote:
> 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
>
> ---
>
> How can I correct this error? Thank you.
> Tim M.
>
>




All times are GMT. The time now is 09:39 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57