Thread: Cannot convert parameter 1 from......

  1. #1
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537

    Cannot convert parameter 1 from......

    Why can I not dereference this MyPolygon pointer?? It is declared here:

    Code:
    class Breakout
    {
    public:
    	Breakout( );
    	~Breakout( );
    	Ball* getBall( ) { return &ball; }
    
    	void run( );
    	void testCollisions( );
    
    
    //data members
    private:
    
    	Ball ball;
    	FrameRate fRate;
    	MyPolygon* boundaries[ 4 ];
    
    	void defineBoundaries( );
    
    };
    but when I try to dereference it here:
    Code:
    void Breakout::testCollisions( )
    {
    	//need to test for intersection wiht boundaries[ 0 ], the top polygon
    	if( intersectPolygon( *boundaries[ 0 ], *ball.getDirection( ), 4 ) )
    		cout << "HIT" << endl;
    }
    I get this error - error C2665: 'intersectPolygon' : none of the 2 overloads can convert parameter 1 from type 'class MyPolygon'

    I've never seen this error before, it normally tells me what I am supposed to be converting it to - but it doesnt

    Oh and here is theintersectPolygon() prototype if its any use:

    bool intersectPolygon( MyPolygon poly, Vector3d* line );


    thx in advance
    Couldn't think of anything interesting, cool or funny - sorry.

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    13
    "boundaries" is an array.
    An array access like boundaries[i] is eqal to *(boundary + i), so boundaries[0] doesn't need to be dereferenced another time.
    operator[] has already done it for you.

    Make also sure that the derefercening of ball.getDirection() is really necessary.

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by teneniel
    boundaries[0] doesn't need to be dereferenced another time.
    operator[] has already done it for you.
    Wrong. Look at the declaration.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Can you post the declaration for MyPolygon?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Code:
    class MyPolygon
    {
    public:
    
    //constructors
    	MyPolygon( );
    	MyPolygon( const Vector3d* array, const int cornerCount );
    	MyPolygon( const MyPolygon& copy );
    	~MyPolygon( );
    
    //functions
    	bool addVertex( Vector3d& vertex );
    	bool removeVertex( Vector3d& vertex );
    	int findVertex( Vector3d& vertex ) const;			//finds a vertex in array and returns the index, returns -1 if not found
    	Vector3d& getPoint( int index ) const;			//returns a point from the array
    	bool defaultDraw( );
    	bool calcNormal( );		//generates the normal
    	int getCornerCount( );
    	Vector3d* getNormal( );
    	void setValues( const Vector3d* array, const int cornerCount );
    	Vector3d* getPoints( );
    
    //operators
    	MyPolygon& operator = ( const MyPolygon& rvalue );
    	friend bool operator == ( const MyPolygon& a, const MyPolygon& b );
    	friend ostream& operator << ( ostream& os, const MyPolygon& poly );
    
    
    private:
    
    //data members
    	Vector3d* points;
    	int corners;
    	Vector3d* norm;
    
    };
    This is the only time I've encountered this, I've used MyPolygon objects before without trouble. Hence the confusion
    Couldn't think of anything interesting, cool or funny - sorry.

  6. #6
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Here is the entry in the msdn about this error, but I'm still no clearer....
    Compiler Error C2665

    'function' : none of the number1 overloads can convert parameter number2 from type 'type'

    The specified parameter of the overloaded function could not be converted to the required type. If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.

    You may need to supply a conversion operator or explicit conversion.
    Couldn't think of anything interesting, cool or funny - sorry.

  7. #7
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Neither am I... weird

    Can you post the prototypes (both) for 'intersectPolygon'?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  8. #8
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Code:
    //THE ray/polygon test function
    bool intersectPolygon( Vector3d* poly, Vector3d* line, int vertexCount );
    
    //overloaded ray/polygon test function
    bool intersectPolygon( MyPolygon poly, Vector3d* line );
    If anyone is willing and able to use OpenGL and GLUT in VC++, I can send them the whole project so far.
    Couldn't think of anything interesting, cool or funny - sorry.

  9. #9
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Ahh.. finally

    You are calling the function with three arguments. However, that function takes a Vector3d*, not a MyPolygon.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  10. #10
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Thank God for that, knew it must've been something simple - it always is!

    Thx for the help Sang-Drax, now to figure out why there is no collision
    Couldn't think of anything interesting, cool or funny - sorry.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-08-2008, 06:31 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. cannot start a parameter declaration
    By Dark Nemesis in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2005, 02:09 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM