B
bugzilla
hi,all,
I have a C++ program need to convert to c language to be used in a
emabedded system. the problem is that the original code was writtern
in C++ language with Parent class and some child class. How can I
invert these C++ code into pure c code by using struct in C language?
Can somebody give me any ideas? thanks.
For example, how to conver the following code into pure c code?
class PARENT
{
public:
virtual int Init();
virtual int Add();
virtual int Sub();
int Otherfunc();
private:
int x;
int y;
int z;
};
class CHILD1: public PARENT
{
public:
int Init();
int Add();
int CHILDOwn();
privete:
int a;
int b;
int c;
};
class CHILD2: public PARENT
{
public:
int Init();
int Add();
int Uncle();
privete:
int m;
int n;
int d;
};
PARENT* CreateNewInstance()
{
PARENT* pPointer=new CHILD1;
return pPointer;
}
main()
{
PARENT * Kids1=CreateNewInstance();
Kids1->Uncle(); //from children class
Kids1->Sub(); //from parent class
Kids1->Otherfunc();//from parent class
}
I have a C++ program need to convert to c language to be used in a
emabedded system. the problem is that the original code was writtern
in C++ language with Parent class and some child class. How can I
invert these C++ code into pure c code by using struct in C language?
Can somebody give me any ideas? thanks.
For example, how to conver the following code into pure c code?
class PARENT
{
public:
virtual int Init();
virtual int Add();
virtual int Sub();
int Otherfunc();
private:
int x;
int y;
int z;
};
class CHILD1: public PARENT
{
public:
int Init();
int Add();
int CHILDOwn();
privete:
int a;
int b;
int c;
};
class CHILD2: public PARENT
{
public:
int Init();
int Add();
int Uncle();
privete:
int m;
int n;
int d;
};
PARENT* CreateNewInstance()
{
PARENT* pPointer=new CHILD1;
return pPointer;
}
main()
{
PARENT * Kids1=CreateNewInstance();
Kids1->Uncle(); //from children class
Kids1->Sub(); //from parent class
Kids1->Otherfunc();//from parent class
}