Solved

No constructor could take the source type, or constructor overload resolution was ambiguous

Posted on 2004-10-13
5
2,016 Views
Last Modified: 2010-05-18
Hi Experts,

   could anyone please tell me what does the following error message mean ??? many thanks !  

error C2440: 'initializing' : cannot convert from 'class Monster *' to 'class Monster'
        No constructor could take the source type, or constructor overload resolution was ambiguous

//-----------------------------------------------------------------
  Monster dragen = new Monster() ;  // line 132
     
   dragen.set_lf(10) ;  //line 134
   dragen.set_i(30) ;
   dragen.set_j(30) ;
   dragen.set_dir(0) ;
//------------------------------------
full error message :

 C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(132) : error C2440: 'initializing' : cannot convert from 'class Monster *' to 'class Monster'
        No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(134) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(134) : error C2501: 'dragen' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(134) : error C2371: 'dragen' : redefinition; different basic types
        C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(132) : see declaration of 'dragen'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(134) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(135) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(135) : error C2501: 'dragen' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(135) : error C2371: 'dragen' : redefinition; different basic types
        C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(132) : see declaration of 'dragen'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(135) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(136) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(136) : error C2501: 'dragen' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(136) : error C2371: 'dragen' : redefinition; different basic types
        C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(132) : see declaration of 'dragen'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(136) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(137) : error C2143: syntax error : missing ';' before '.'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(137) : error C2501: 'dragen' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(137) : error C2371: 'dragen' : redefinition; different basic types
        C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(132) : see declaration of 'dragen'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(137) : error C2143: syntax error : missing ';' before '.'
Generating Code...
Error executing cl.exe.
0
Comment
Question by:meow00
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
avizit earned 350 total points
ID: 12304923
>>> Monster dragen = new Monster()

"dragen"  is of type "Monster"

while "new" returns a pointer to  Monster
0
 
LVL 1

Author Comment

by:meow00
ID: 12304939
thanks a lot ....
but I still have "missing ';' before '.'  " if I do :
------------------------------------------------
 Monster dragen  ;    
   dragen.set_lf(10) ;  //line 134
   dragen.set_i(30) ;
   dragen.set_j(30) ;
   dragen.set_dir(0) ;
---------------------------
does anyone have any idea ??? many thanks !!!
0
 
LVL 11

Expert Comment

by:avizit
ID: 12304956
The above lines i guess are insufficient to deduce

can you try pasting lines 120-140  of MyMap.cpp
0
 
LVL 1

Author Comment

by:meow00
ID: 12304987
err ... it is kind of disgusting .... but here it is :

-----------------------------------------------------------
 int sceneIndex[rows][cols] = {0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1,  0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1, // the first row
                                  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,// the second row
                                                0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,  0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,// the third row
                                                0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,  0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,// the 4th row
                                                2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,  2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,// the 5th row
                                                0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,// the 6th row
                                                0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,  0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,// the 7th row
                                                0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,  0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,// the 8th row
                                                1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,  1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,// the 9th row
                                                2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0,  2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0,// the 10th row
                                                0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1,  0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1,// the first row
                                  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,// the second row
                                                0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,  0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,// the third row
                                                0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,  0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,// the 4th row
                                                2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,  2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,// the 5th row
                                                0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,// the 6th row
                                                0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,  0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,// the 7th row
                                                0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,  0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,// the 8th row
                                                1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,  1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,// the 9th row
                                                2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0,  2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0, //  } ; // the 10th row
                                0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1,  0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1, // the first row
                                  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,// the second row
                                                0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,  0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,// the third row
                                                0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,  0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,// the 4th row
                                                2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,  2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,// the 5th row
                                                0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,// the 6th row
                                                0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,  0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,// the 7th row
                                                0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,  0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,// the 8th row
                                                1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,  1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,// the 9th row
                                                2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0,  2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0,// the 10th row
                                                0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1,  0,2,2,0,2,  0,1,0,1,1, 0,2,2,0,2,  0,1,0,1,1,// the first row
                                  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,  0,0,0,0,0,  0,0,1,1,0, 0,0,0,0,0,  0,0,1,1,0,// the second row
                                                0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,  0,0,0,0,0,  0,1,0,1,0, 0,0,0,0,0,  0,1,0,1,0,// the third row
                                                0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,  0,0,1,0,1,  0,0,0,2,0, 0,0,1,0,1,  0,0,0,2,0,// the 4th row
                                                2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,  2,2,0,0,1,  0,0,0,0,2, 2,2,0,0,1,  0,0,0,0,2,// the 5th row
                                                0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0,  0,0,0,0,0, 0,0,0,0,0,  0,0,0,0,0,// the 6th row
                                                0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,  0,0,1,0,0,  0,0,0,1,0, 0,0,1,0,0,  0,0,0,1,0,// the 7th row
                                                0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,  0,0,0,0,0,  0,1,1,1,1, 0,0,0,0,0,  0,1,1,1,1,// the 8th row
                                                1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,  1,0,0,0,0,  0,0,0,0,1, 1,0,0,0,0,  0,0,0,0,1,// the 9th row
                                                2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0,  2,0,0,0,0,  0,0,0,0,0, 2,0,0,0,0,  0,0,0,0,0 } ; // the 10th row
 

 //       Monster *dragen = new Monster[30] ;
//      dragen[0] = new Monster() ;
     
  //  dragen[0].set_lf(10) ;
//      dragen[0].set_i(30) ;
//      dragen[0].set_j(30) ;
//      dragen[0].set_dir(0) ;

 
   Monster dragen ;
     
   dragen.set_lf(10) ;
   dragen.set_i(30) ;
   dragen.set_j(30) ;
   dragen.set_dir(0) ;
 
  // Foward declarations of functions included in this code module:
ATOM                        MyRegisterClass(HINSTANCE hInstance);
BOOL                        InitInstance(HINSTANCE, int);
LRESULT CALLBACK      WndProc(HWND, UINT, WPARAM, LPARAM);
------------------------------------
please help ... many thanks !!!
0
 
LVL 11

Expert Comment

by:avizit
ID: 12305073
I am sorry i cant find anythng in the listing above ..
basically you need to scan carefully the program MyMap.cpp  from line 132 upwards .. you may have missed a ";" or some other punctuation .
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question