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

Discussion in 'C++' started by John Harrison, Jun 25, 2003.

  1. "Tim Mierzejewski" <> wrote in message
    news:H%kKa.6098$...
    > 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
     
    John Harrison, Jun 25, 2003
    #1
    1. Advertising

  2. > 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.
     
    Tim Mierzejewski, Jun 25, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Suzanne
    Replies:
    0
    Views:
    1,044
    Suzanne
    Jun 25, 2003
  2. Jack Klein
    Replies:
    0
    Views:
    2,731
    Jack Klein
    Jun 25, 2003
  3. David Hoffman

    Compile error C2664 - Why??

    David Hoffman, Oct 11, 2003, in forum: C++
    Replies:
    4
    Views:
    3,723
    David Hoffman
    Oct 12, 2003
  4. mkarja

    Compiler error C2664

    mkarja, Feb 6, 2005, in forum: C++
    Replies:
    1
    Views:
    1,700
    David Lindauer
    Feb 6, 2005
  5. kaizen
    Replies:
    3
    Views:
    4,782
    Jim Langston
    Jan 21, 2006
Loading...

Share This Page