?
Solved

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

Posted on 2004-10-13
5
Medium Priority
?
2,153 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 1050 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

719 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