Das Folgende ist der Code, aber ich weiß nicht, wie man es debuy. Kann mir jemand helfen?Fehler ungültige Konvertierung von 'int *' zu 'int' -fpermissive
#include <iostream>
using namespace std;
class CSample
{
int *x;
int N;
public:
//dafualt constructor
CSample(): x(NULL)
{}
void AllocateX(int N)
{
this->N = N;
x = new int[this->N];
}
int GetX()
{
return x;
}
~CSample()
{
delete []x;
}
};
int main()
{
CSample ob1; //Default constructor is called.
ob1.AllocateX(10);
//problem with this line
CSample ob2 = ob1; //default copy constructor called.
CSample ob3; //Default constructor called.
//problem with this line
ob3 = ob1; //default overloaded = operator function called.
}
GetX sollte entweder vom Typ int * oder return int sein. Sie haben auch keinen Kopierkonstruktor definiert. Bitte stellen Sie sicher, dass Sie Ihre Frage in Zukunft korrekt formatieren und ein minimales, vollständiges und überprüfbares Beispiel angeben. –
"Ich weiß nicht, wie man es debuggt" - bitte werfen Sie einen Blick auf [Wie kleine Programme zu debuggen] (https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) von Eric Lippert, es ist ein * exzellenter * Artikel über Debugging-Techniken. – EJoshuaS