Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Leda > How to implemen...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 194 of 212
Post > Topic >>

How to implement C++ class heritage properties in C using C struct?

by mozilla.bugzilla@[EMAIL PROTECTED] (bugzilla) Mar 18, 2005 at 01:55 PM

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
}
 




 1 Posts in Topic:
How to implement C++ class heritage properties in C using C stru
mozilla.bugzilla@[EMAIL P  2005-03-18 13:55:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 20:01:01 CDT 2008.