Solved

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

Posted on 2004-10-13
5
2,048 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Embarcadero C++ Builder XE2 TDateTime 8 92
How to split this in C++ 4 130
Exception thrown at 0x00007FFD5BC81F28 7 62
C++ Code Issue 4 48
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 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