Solved

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

Posted on 2004-10-13
5
2,102 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

617 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