Thread: Why can't I do the second method?

  1. #1
    Registered User
    Join Date
    Oct 2012

    Why can't I do the second method?

    Working method:

    sf::Vector2i *position = &sf::Mouse::getPosition();
    Now, that works just fine. But, why can't I just do:

    gui.didClickButton(sf::Vector2i &sf::Mouse::getPosition());

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    This is the same error for the same reasons as before.

    You seem to have an issue reading the difference between a pointer expression (&sf::Mouse::getPosition()) and a reference declaration. What I think you need to be told is that a pointer expression is not preceded by a type name, unless it is being cast the C way. Usually pointer expressions can be function arguments or values on the left hand side of an assignment statement. The difference between that and a reference declaration is that a reference declaration is a statement on its own.

    sf::Vector2i& reference;
    Normally you wouldn't try to use this exact statement as a pointer argument.

  3. #3
    Registered User
    Join Date
    Oct 2012
    Aha, never mind. I understand now. Can't believe I didn't figure that one out. >.<


    Thanks. ^.^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. difference between this->method() and method()
    By nacho4d in forum C++ Programming
    Replies: 7
    Last Post: 11-21-2009, 03:11 PM
  2. Encrypt method (from decrypt method)
    By mmmmmm in forum C# Programming
    Replies: 3
    Last Post: 09-19-2009, 10:35 AM
  3. calling a class method within different class method
    By alyeska in forum C++ Programming
    Replies: 5
    Last Post: 03-08-2009, 10:56 AM
  4. another method?
    By me77 in forum C Programming
    Replies: 4
    Last Post: 04-19-2008, 05:41 PM
  5. need help with a method
    By laasunde in forum C++ Programming
    Replies: 17
    Last Post: 10-28-2002, 11:08 AM