Questions tagged [c2664]

C2264 is a Compiler Error that occurs when one tries to pass a function a parameter of an incompatible type.

C2264 is a Compiler Error that occurs when one tries to pass a function a parameter of an incompatible type.

This example generates C2264:

// C2664b.cpp
// C2664 expected
struct A {
   // To resolve, uncomment the following line.
   // A(int i){}
};

void func( int, A ) {}

int main() {
   func( 1, 1 );   // No conversion from int to A.
}
52 questions
5
votes
1 answer

Visual C++:error C2664: 'GetModuleFileNameW' : cannot convert parameter 2 from 'char [260]' to 'LPWCH'

when I tried to compiling my project I got some errors that I can't solve.. anyway this is the one of the codes: public: void Init(HMODULE hModule, string Filename) { char szLoc[ MAX_PATH ]; GetModuleFileName(hModule, szLoc, sizeof( szLoc )…
user1276261
  • 51
  • 1
  • 2
5
votes
2 answers

Using a template callback function in C++

I want to have a function that checks certain conditions based on a given callback function. Considers this code: class Foo{ template struct IsGood { typedef bool (*Check)(typename const ParamType*, int other); }; template<…
Flamefire
  • 3,954
  • 2
  • 22
  • 50
3
votes
2 answers

Errors C2664 and E0167, stumped

I'm taking a c++ beginner's distance class and can't solve this compile error. It's written exactly as in the example book, and when my brother cuts and pastes it into his VS2015 it works fine, but in my VS2017 it doesn't. I have uninstalled and…
Jeppen
  • 31
  • 1
  • 3
3
votes
1 answer

Error C2664 when trying to create unique_ptr

I'm trying to figure out a problem I have in my project, and I have simplified it down to this little bit of code that generates the C2664 error. I don't understand the error message, could anyone help me to understand? I've googled, and I've looked…
taurous
  • 139
  • 6
3
votes
5 answers

C++: using std::wstring in API function

I'm using the SHGetSpecialFolderLocation API function. My application is set to "Use Unicode Character Set". Here's what I have so far: int main ( int, char ** ) { LPITEMIDLIST pidl; HRESULT hr = SHGetSpecialFolderLocation(NULL,…
guitar-
  • 921
  • 5
  • 14
  • 20
3
votes
2 answers

Converting 'const char*' to 'LPCTSTR' for CreateDirectory

#include "stdafx.h" #include #include using namespace std; int main() { string FilePath = "C:\\Documents and Settings\\whatever"; CreateDirectory(FilePath, NULL); return 0; } Error: error C2664: 'CreateDirectory' :…
ProGirlXOXO
  • 1,777
  • 4
  • 21
  • 36
2
votes
3 answers

Passing in an Object to an abstract type's constructor in C++

I'm trying to create CnD_Message_Handler of parent type i_MessageHandler. i_MessageHandler constructor takes a i_MessageFactory, another abstract class. CnD_Message_Factory inherits from i_MessageFactory. When I try to instantiate the…
Kat
  • 429
  • 1
  • 6
  • 20
2
votes
3 answers

How can i convert pointer-method of some class to pointer-function?

Greating everybody! I have a function-pointer method int Myclass::*myMethod(char* a,char* b){ //some code } And try to run it bool Myclass::myMethod2(){ AnotherClass *instance = AnotherClass:getInstance(); instance->…
Stepchik
  • 267
  • 1
  • 2
  • 14
2
votes
5 answers

error C2664: cannot convert parameter 1 from 'int' to 'int (__cdecl *)(int)'

having some trouble passing a function as a parameter of another function... ERROR: Error 1 error C2664: 'wrapper' : cannot convert parameter 1 from 'int' to 'int (__cdecl *)(int)' int inc( int n ) { return n + 1 ; } int dec( int n…
tuk
  • 307
  • 1
  • 3
  • 10
2
votes
1 answer

error C2664 : 'void std::vector<_Ty>::push_back(_Ty&&)': cannot convert parameter 1 from 'Node *' to 'Node&&'

error C2664 : 'void std::vector<_Ty>::push_back(_Ty&&)': cannot convert parameter 1 from 'Node *' to 'Node&&' please I need help... I created node.h & heap.h node.h : #ifndef __NODE_H_ #define __NODE_H_ #include #include using…
Gil Yosef
  • 45
  • 1
  • 4
2
votes
1 answer

Best practice for handling down casts due to C++ C2664 when compiling 64 bit

I have an exposed method that accepts a long* as a parameter like this: void MyClass::MyPublicMethod(long *pLong) Inside this method, I call a system API that accepts an INT64*, like this: void MyClass::MyPublicMethod(long *pLong) { …
BarryE
  • 29
  • 1
2
votes
1 answer

C2664 error c++ Visual Studio

I am trying to modify an old MFC program. After opening the project in Visual Studio 2013 there are many errors of the type below. In AviPlay.cpp #include "stdafx.h" #include "AviPlay.h" #define OPEN_AVI_VIDEO "open avivideo" BOOL initAVI() { …
user3931552
  • 21
  • 1
  • 2
1
vote
2 answers

How to resolve error C2664 _vswprintf_c_l error in visual studio 2005?

The error shown: Error 11 error C2664: '_vswprintf_c_l' : cannot convert parameter 4 from 'void *' to '_locale_t' C:\Program Files\Microsoft Visual Studio 8\VC\include\swprintf.inl 41 It locates the file- C:\Program Files\Microsoft Visual…
Gulshan
  • 2,973
  • 5
  • 31
  • 44
1
vote
3 answers

Keep getting C2664 error - cannot convert argument from char[10] to char

I keep getting an C2664 error, "cannot convert argument 1 from char[10] to char" when I attempt to compile and run. I've tried replacing arrays with pointers (char answer[] to char * answers). I can do this without passing arrays to a function,…
1
vote
1 answer

C++ c2664 error "cannot convert argument 1 from std::string to _Elem *"

I've been stuck on this homework assignment all week. Just when I get the program to finally run, I realize that by using just cin >> breed, if my input has a space it ruins the code (as my program requires gathering 3 separate variables, first an…
gaara
  • 13
  • 4
1
2 3 4