Point*& to Point&

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2008
Posts: 2
Reputation: JD2000 is an unknown quantity at this point 
Solved Threads: 0
JD2000 JD2000 is offline Offline
Newbie Poster

Point*& to Point&

 
0
  #1
Dec 4th, 2008
I'm currently working on implementing a small game in C++, but when trying to compile, I get this error:

  1. ..quadtree.h:125: error: no matching function for call to 'Fleet::Ship::overlaps(const Fleet::Ship*&)'
  2. ..ship.h:40: note: candidates are: bool Ship::overlaps(const Rectangle&) const
  3. ..ship.h:85: note: bool Ship::overlaps(const Ship&) const
  4. ..ship.h:32: note: bool Ship::overlaps(const Point&) const

So I think I now have Ship*&, which should actually be Ship&.
Is there any way to convert Ship*& to Ship&?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 118
Reputation: chococrack is on a distinguished road 
Solved Threads: 14
chococrack's Avatar
chococrack chococrack is offline Offline
Junior Poster

Re: Point*& to Point&

 
0
  #2
Dec 4th, 2008
Post your code.
I would love to change the world, but they won't give me the source code
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Point*& to Point&

 
0
  #3
Dec 4th, 2008
Originally Posted by JD2000 View Post
So I think I now have Ship*&, which should actually be Ship&.
Is there any way to convert Ship*& to Ship&?
Yes, of course: use unary operator *(). But I'm not sure that it helps
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

Re: Point*& to Point&

 
0
  #4
Dec 5th, 2008
  1. //...
  2. Ship old_ship;
  3. Ship *new_ship=new Ship;
  4. old_ship.overlaps(new_ship);
  5. //...
i'm not sure too..
Last edited by cikara21; Dec 5th, 2008 at 4:01 am.
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 8
Reputation: sweeya is an unknown quantity at this point 
Solved Threads: 1
sweeya sweeya is offline Offline
Newbie Poster

Re: Point*& to Point&

 
0
  #5
Dec 5th, 2008
Use the following to make the function call

[code = C++]
old_ship.overlaps(*new_ship);
[/code]

You have defined to function to catch a reference and you are sending pointer the object which would be a mismatch
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: Point*& to Point&

 
0
  #6
Dec 5th, 2008
In the function call here
  1. 'Fleet::Ship::overlaps(const Fleet::Ship*&)'
you are passing a pointer instead of a reference. Dereference the parameter by prefixing it with a '*'.

  1. class A;
  2.  
  3. void func(A & a) {...}
  4.  
  5. A a;
  6. A *p = &a;
  7. func(*p); // like this
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 2
Reputation: JD2000 is an unknown quantity at this point 
Solved Threads: 0
JD2000 JD2000 is offline Offline
Newbie Poster

Re: Point*& to Point&

 
0
  #7
Dec 9th, 2008
It's all solved now

Thanks

btw dereferencing the parameters worked
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC