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.
}
56 questions
1
vote
2 answers

Error C2664: cannot convert argument 1 from 'imaging::component_t *' to 'const imaging::component_t *&'

I have the error I mentioned in the title on this part of my code. component_t *buffer = new component_t[3 * width*height]; component_t getRawDataPtr(); ... for (unsigned int i = 0; i < width*height * 3; i = i + 3) { file.read((char…
Sakis95
  • 49
  • 1
  • 4
  • 12
1
vote
2 answers

why can't i pass two different comparators to one template function?

I'm wracking my brain here for several hours, but I still don't understand why I'm getting an error when I'm trying to run this code. After some time I managed to narrow it down to the expression: pastryPrice() which causes the problem - as you…
prowler
  • 15
  • 4
1
vote
1 answer

Map insert results in C2664 error in VS 2015, works in VS 2013

This piece of code was working perfectly in VS 2013 but I had to update to VS 2015 and now it throws an error. I did read https://msdn.microsoft.com/en-us/library/s5b150wd.aspx and googled quite a bit however I still have no idea how to fix…
Carl
  • 705
  • 8
  • 22
1
vote
1 answer

When I run the C++ code, I always get Visual Studio error C2664

When I use this code if (GetKeyNameText(Key << 16, NameBuffer, 127)) { KeyName = NameBuffer; GoodKeyName = true; } I get the following error C2664 'int GetKeyNameTextW(LONG,LPWSTR,int)': cannot convert argument 2 from 'char [128]' to…
Hanzki
  • 11
  • 1
  • 4
1
vote
2 answers

error C2664: multimap in map

Here is my code: map> mp; string str1 = "abc"; string str2 = "def"; string str3 = "ghi"; mp.insert(str1, {str2, str3}); I got an error C2664: 'void…
Yves
  • 11,597
  • 17
  • 83
  • 180
1
vote
0 answers

How can I make the c++ chrono steady_clock stop returning system_clock times?

I was writing a class that dealt with optional time constraints for certain methods, and so it takes classes from the std::chrono namespace to specify how to define the times. I was trying to test this method that is supposed to expire once it…
1
vote
4 answers

pushing back a class object into a vector

I have a vector that takes in a class object but when I try to push back the object I have created into the vector I am getting these problems and don't know how to getnaround it. Can anyone help me please ? void populate( std::vector vNav,…
1
vote
1 answer

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

#include using namespace std; bool is_different(int x, int y, int z); int max_of_three(int x, int y, int z); int greater_of_two(int x, int y); int min_of_three(int x, int y, int z); int smaller_of_two(int x, int y); void print_result(int…
0
votes
3 answers

Incomprehensible VC++6 compile error C2664

I can't figure out how to fix a compile error C2664, which has driven me crazy all night! The error arises from a call to qsort(). I want to sort an array of ID2IX stored in the array pointed by radioIDs: typedef struct id2ix { // struct maps…
Pete Wilson
  • 8,610
  • 6
  • 39
  • 51
0
votes
1 answer

Why does compiling my project to dll give error codes C2664 and E0289 error when compiling?

BOOL CALLBACK callback(HWND hwnd, LPARAM param) { DWORD pid; GetWindowThreadProcessId(hwnd, &pid); if (pid == param) { TCHAR classNameBuf[MAX_PATH]; GetClassName(hwnd, classNameBuf, MAX_PATH); std::string…
Queirbeer
  • 1
  • 1
0
votes
3 answers

error c2664 upon using basic_string abc("hello") in vc++ 9.0

Hi upon compiling this code in Visual studio 2008 i get the following error #include #include using namespace std; void main() { basic_string abc("hello world"); cout<
Anirudh Goel
  • 4,571
  • 19
  • 79
  • 109
0
votes
1 answer

How do you think I can solve Error C2664?

I have little problem. I am getting the error mentioned in the title while compiling. The line where the error appears is pItemData->GetName(), line. But even if I change the order, whatever is on that line gives the same error about it. When I…
cvaqabond
  • 23
  • 3
0
votes
0 answers

Can I solve "returning address of local variable or temporary" without changing other functions in the code?

When running the following code I get the error: returning address of local variable or temporary trying to solve the issue my idea was to change n_date to: char* n_date = (char*)malloc(sizeof(char) * 60); However, since I am not allowed to modify…
ValSe
  • 33
  • 1
  • 1
  • 5
0
votes
1 answer

What does this error mean: "error C2664 cannot convery arguement 7 from 'TCHAR (*)[261]' to 'LPSTR'

I'm new to coding and I'm not too sure how I'd go about fixing this issue. The error is as follows: error C2664: 'BOOL GetVolumeInformationA(LPCSTR,LPSTR,DWORD,LPDWORD,LPDWORD,LPDWORD,LPSTR,DWORD)': cannot convert argument 7 from 'TCHAR (*)[261]'…
0
votes
0 answers

Understanding std::thread constructor call with member function that takes parameters

I'm trying to code a simple client-server-application with winSock to better understand how it all works. The server should be able to support multiple clients and therefore starts a new thread for receiving client messages each time a new client…