长话短说:
class A {
public:
A();
~A();
void SetID(char* ID);
char* GetID();
protected:
char ID[10];
};
class B: public A {
public:
B();
~B();
protected:
...
private:
...
};
然后主要:
...
B *temp = new B;
temp->SetID("0x12345678");
...
然后编译器说“预期的构造函数,析构函数或类型转换之前->令牌”其中“temp->SetID(“0x12345678”)”位于
有人给点提示吗??
Loki 建议的整个程序:
#include <iostream>
using namespace std;
class A {
public:
A();
~A();
void SetID(char* id);
char* GetID();
protected:
char ID[10];
};
void A::SetID(char* id){
strcpy(ID,id);
}
char* A::GetID(){
return ID;
}
class B: public A {
public:
B();
~B();
protected:
int num;
};
int main(){
B *temp = new B;
B->SetID("0x12345678");
cout<<B->GetID()<<endl;
return 0;
}