How to convert a C code into C++
I need to convert a big C project into C++.
Can anyone tell me how to do this?
What are the steps must be taken to do this?
or is there any tool to do this?
or any nice articles abt this?
Thanx in advance.
It depends on what you mean. If you want to make a C project object oriented, you will have to do it by hand with a redesign of the code (unless its a rare, struct and function pointer OO C project-- very few are like this!). I recommend understand C (you can download a trial version) if you do not know what the code does and how it does it. If you just want to compile it, a c++ compiler can already compile C files. If you want to change the extensions to .cpp, you don't have to do much, just fix the malloc's and a couple of other small things (the compiler will tell you). Normally, unless you plan to do a major overhaul that is about the same as starting over, OO-ing it is not a good path to go down.
Thanx a lot for ur suggestions.
First off, try to compile it as a C++ project (you'd probably need to change the file extensions) and see which compilation errors you're getting. Then fix these errors. Depending on the C subset you're using, these errors can be minimal or a torrent of corrections. For example. if your functions don't have prototypes, then you will have to fix that. Similarly, if your code uses void * all over the place you will need to add explicit casting operators etc.
Don't rush to make it object-oriented. If it works correctly and satisfactorily, leave it as is so long as the code complies with ISO C++. Refactoring it to OO requires a serious design and recoding processes; it's not just throwing a bunch of classes into what used to be C code. This is in fact a mistake that many people do when they migrate from C to C++.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL