Compiler Error C2660

'function' : fungsi tidak mengambil parameter angka

Komentar

Fungsi ini dipanggil dengan jumlah parameter yang salah.

C2660 dapat terjadi jika Anda secara tidak sengaja memanggil fungsi Api Windows daripada fungsi anggota MFC dengan nama yang sama. Untuk mengatasi masalah ini:

  • Sesuaikan panggilan fungsi agar sesuai dengan format panggilan fungsi anggota.

  • Gunakan operator resolusi cakupan (::) untuk memberi tahu pengkompilasi untuk mencari nama fungsi di ruang nama global.

Contoh

Contoh berikut menghasilkan C2660.

// C2660.cpp
void func( int, int ) {}

int main() {
   func( 1 );   // C2660 func( int ) not declared
   func( 1, 0 );   // OK
}

C2660 juga dapat terjadi jika Anda mencoba langsung memanggil metode Buang dari jenis terkelola. Untuk informasi selengkapnya, lihat Destructor dan finalizer. Contoh berikut menghasilkan C2660.

// C2660_a.cpp
// compile with: /clr
using namespace System;
using namespace System::Threading;

void CheckStatus( Object^ stateInfo ) {}

int main() {
   ManualResetEvent^ event = gcnew ManualResetEvent( false );
   TimerCallback^ timerDelegate = gcnew TimerCallback( &CheckStatus );
   Timer^ stateTimer = gcnew Timer( timerDelegate, event, 1000, 250 );

   stateTimer->Dispose();   // C2660
   stateTimer->~Timer();   // OK
}

C2660 akan terjadi jika kelas turunan menyembunyikan fungsi.

// C2660b.cpp
// C2660 expected
#include <stdio.h>

class f {
public:
   void bar() {
      printf_s("in f::bar\n");
    }
};

class f2 : public f {
public:
   void bar(int i){printf("in f2::bar\n");}
   // Uncomment the following line to resolve.
   // using f::bar;   // - using declaration added
   // or
   // void bar(){__super::bar();}
};

int main() {
   f2 fObject;
   fObject.bar();
}

C2660 dapat terjadi jika Anda salah memanggil properti terindeks.

// C2660c.cpp
// compile with: /clr
ref class X {
   double d;
public:
   X() : d(1.9) {}
   property double MyProp[] {
      double get(int i) {
         return d;
      }
   }   // end MyProp definition
};

int main() {
   X ^ MyX = gcnew X();
   System::Console::WriteLine(MyX->MyProp(1));   // C2660
   System::Console::WriteLine(MyX->MyProp[1]);   // OK
}

C2660 dapat terjadi jika Anda salah memanggil properti terindeks.

// C2660d.cpp
// compile with: /clr
ref class A{
public:
   property int default[int,int] {
      int get(int a, int b) {
         return a + b;
      }
   }
};

int main() {
   A^ a = gcnew A;
   int x = a[3][5];   // C2660
   int x2 = a[3,5];   // OK
}

C2660 dapat terjadi jika Anda menentukan operator baru di kelas templat, tetapi di mana operator baru membuat objek yang jenisnya selain jenis penutup.

// C2660e.cpp
// compile with: /c
#include <malloc.h>

template <class T> class CA {
private:
    static T** line;
   void* operator new (size_t, int i) {
      return 0;
   }
   void operator delete(void* pMem, int i) {
      free(pMem);
   }

public:
   CA () { new (1) T(); }   // C2660
   // try the following line instead
   // CA () { new (1) CA<int>(); }
};

typedef CA <int> int_CA;

void AAA() {
   int_CA  list;
}