Solved

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

Posted on 2004-10-13
5
1,953 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
Comment Utility
>>> Monster dragen = new Monster()

"dragen"  is of type "Monster"

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

Author Comment

by:meow00
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now