Error C2664 Cannot Convert Parameter 1 From
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 error c2664 cannot convert parameter 1 from 'const char *' to 'char *' the company Business Learn more about hiring developers or posting ads with us Stack Overflow error c2664 cannot convert parameter 1 from const char to lpcwstr Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of
Error C2664 In Visual C++
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 from 'int' to 'int []' up vote 0 down vote favorite #include
Error C2664 Cannot Convert Parameter From Const Char To Lpcwstr
using namespace std; class amin { private: 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] = 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 herohuyon
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
Cannot Convert Argument 1 From Int [] To Int
site About Us Learn more about Stack Overflow the company Business Learn more cannot convert parameter 1 from 'char *' to 'lpcwstr' about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x error c2440 Dismiss Join the 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: http://stackoverflow.com/questions/22150353/error-c2664-cannot-convert-parameter-1-from-int-to-int cannot convert parameter 1 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 // http://stackoverflow.com/questions/14713648/error-c2664-cannot-convert-parameter-1-from-x-to-x --- END MyObject.h // --- BEGIN 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\engin
consists of 13 header files and of 12 cpp file. I've created a procedure in a cpp file called PCA.cpp. This is the content of error c2664 the file: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdafx.h" #include "alglibinternal.h" #include "alglibmisc.h" #include "ap.h" #include "dataanalysis.h" #include "gauss.h" #include "linalg.h" #include "optimization.h" #include "solvers.h" #include "specialfunctions.h" #include "statistics.h" #include using namespace std; using namespace alglib; using cannot convert parameter namespace alglib_impl; void Princ(char img1[30], char img2[30], char img3[30], char img4[30]) { //remove(argv[5]); TIFF *tif1, *tif2, *tif3, *tif4; tif1 = TIFFOpen(img1, "r"); tif2 = TIFFOpen(img2, "r"); tif3 = TIFFOpen(img3, "r"); tif4 = TIFFOpen(img4, "r"); // ... others parts of code, but img1 img2 img3 img4 will no longer be used } Header files that I've included are needed to solve some function used in Princ procedure. In the main file called pcasogl.cpp I wrote: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "gauss.h" #include #include #include #include using namespace std; extern void Princ(char, char, char, char); // main program int main(int ar