Error C2664 In
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn
Error C2664 Lpcwstr
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags error c2440 Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you,
Error C2664 In C++
helping each other. Join them; it only takes a minute: Sign up error C2664: cannot convert parameter 1 from 'int' to 'int []' up vote 0 down vote favorite #include using namespace std; class amin { private: error c2664 messageboxw const int length = 10; int newArray[length]; int i; public: int deleteEvenNumber(int getArray[length]) { for (i = 0 ; i < length ; i++) { if (getArray[i] % 2 == 0) newArray[i] = getArray[i]; i++; }; return newArray[length]; }; }; main: int main() { amin manipulateArrays; int input , i = 0; const int length = 10; int mainArray[length]; cout<<"Please enter ten numbers :"<>input; mainArray[i] error c2059 = input; i++; }; manipulateArrays.deleteEvenNumber(mainArray[length]); }; i got these two errors: error C2664: 'amin::deleteEvenNumber' : cannot convert parameter 1 from 'int' to 'int []' IntelliSense: argument of type "int" is incompatible with parameter of type "int *" please help and explain about my mistake to me. and please introduce a good tutorial for this problem or this title to me. c++ casting share|improve this question edited Mar 3 '14 at 15:23 herohuyongtao 25.4k96691 asked Mar 3 '14 at 15:13 Amin Khormaei 492312 I would use a std::vector rather than arrays. –Nick Mar 3 '14 at 15:17 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted Your function deleteEvenNumber() requires an int [] (i.e. int array), however you passed it an int to it. manipulateArrays.deleteEvenNumber(mainArray[length]); ^^^^^^^^^^^^^^^^^ | this is an 'int', not an 'int []' To also pass the length to the function, you may want to change your function to int deleteEvenNumber(int getArray[], int length) And then call it like: manipulateArrays.deleteEvenNumber(mainArray, length); Alternatively, you can use vector mainArray instead, and then you can easily get its length by mainArray.size(). share|improve this answer edited Mar 3 '14 at 15:21 answered Mar 3 '14 at 15:15 herohuyongtao 25.4k96691 And what about length? It won't compile... –Nick Mar 3 '14 at 15:17 1 @Nick Fixed. thanks. –herohuyongtao Mar 3
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About
Error C2664 Cannot Convert
Us Learn more about Stack Overflow the company Business Learn more about hiring error c2664 lpctstr developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the
Error Lnk2019
Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error C2664: cannot convert parameter 1 http://stackoverflow.com/questions/22150353/error-c2664-cannot-convert-parameter-1-from-int-to-int from 'X' to 'X' up vote 1 down vote favorite I have a C++/Win32/MFC project in Visual Studio 2008, and I'm getting a strange error message when I compile it. I've created a small project to demonstrate the problem, and the main code is #ifndef _MyObject_h #define _MyObject_h class MyObject { public: MyObject() { } }; #endif // _MyObject_h // --- END MyObject.h // --- BEGIN http://stackoverflow.com/questions/14713648/error-c2664-cannot-convert-parameter-1-from-x-to-x ObjectData.h #ifndef _ObjectData_h #define _ObjectData_h template class ObjectData { public: DataPolicy *data; ObjectData() : data(NULL) { } ObjectData(const ObjectData ©) : data(copy.data) { } ObjectData & operator=(const ObjectData ©) { this->data = copy.data; return *this; } }; #endif // _ObjectData_h // --- END ObjectData.h // --- BEGIN Tool.h #ifndef _Tool_h #define _Tool_h #include "ObjectData.h" template class Tool { private: ObjectData _object; public: Tool(ObjectData obj); }; #endif // _Tool_h // --- END Tool.h // --- BEGIN Tool.cpp #include "stdafx.h" #include "Tool.h" template Tool::Tool(ObjectData obj) : _object(obj) { } // --- END Tool.cpp // --- BEGIN Engine.h #ifndef _Engine_h #define _Engine_h #include "Tool.h" #include "MyObject.h" class Engine { private: MyObject *_obj; public: Engine(); ~Engine(); void DoSomething(); }; #endif // _Engine_h // --- END Engine.h // --- BEGIN Engine.cpp #include "stdafx.h" #include "Engine.h" Engine::Engine() { this->_obj = new MyObject(); } Engine::~Engine() { delete this->_obj; } void Engine::DoSomething() { ObjectData objData; objData.data = this->_obj; // NEXT LINE IS WHERE THE ERROR OCCURS Tool< ObjectData > *tool = new Tool< ObjectData >(objData); } // --- END Engine.cpp Errors: Engine.cpp c:\projects\myproject\myproject\engine.cpp(18) : error C2664: 'Tool::Tool(ObjectData)' : cannot convert parameter 1 from 'ObjectData' to
gives me this error "error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'int' to 'const Item &'" and "error C2679: binary '<<' : no operator http://www.cplusplus.com/forum/general/17903/ found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)'" I tried everything to fix it but it just wouldnt work at all.. can anyone help me please? heres the code int buyNo; vector- items; bool finished = false; cout << "Enter the itemID (Example: 4) Type 0 when you are finished" << endl; while (finished == false) { cin >> buyNo; error 1 is this error c2664 line items.push_back(buyNo); if (buyNo == 0) { finished = true; } } cout << "You have chosen:" << endl; for (int i=0;i<(int)items.size();i++) { Error 2 is this line cout << items.pop_back() << endl; } Thank you so much for looking!!!! much appreciated Last edited on Jan 3, 2010 at 9:40pm UTC Jan 3, 2010 at 9:41pm UTC kbw (7986) std::vector pop_back returns void. http://www.sgi.com/tech/stl/Vector.html Jan 3, 2010 at 9:44pm UTC helios error c2664 in (13227) error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'int' to 'const Item &'You're trying to push an int to a vector of 'Item's. error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)'std::vector::pop_back() doesn't return anything, and you can't send nothing to std::cout. Jan 3, 2010 at 11:44pm UTC ajeylani (2) kbw.. thanks for the link and thanks for helping!!!!!! helios.. yeh know the problem with the first error but i just dont know how to sort it out, if you can help me with that, that would be great! THANK YOU GUYS Jan 4, 2010 at 1:40pm UTC kbw (7986) You need to show us what an Item is. It's not obvious you work out an Item given an ItemID. Jan 4, 2010 at 3:39pm UTC moorecm (1932) For the first error, there is no implicit type conversion available to do the conversion. Implicit type conversions can be created via a single-argument constructor or a conversion operator. For the second, consider using the vector::back() method for the output before calling pop_back(). Last edited on Jan 4, 2010 at 3:41pm UTC Topic archived. No new replies allowed. C++ Information Tutorials Reference Articles Forum Forum BeginnersWindows ProgrammingUNIX/Linux Programming