Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-25-2004, 04:29 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
mixing c with c++ and oop?

well i've got some really good midi stuff happening now. it is programmed in C.

now i am at a point to where i'd like to make classes .. as i'm self taught in this area ( or helped along by you all ) i am wondering if it is common to port programs from c to c++ so i can then program OO.

is there really any porting besides just making the classes which will turn it into c++ ?
__________________
Mike
sde is offline   Reply With Quote
Old 05-25-2004, 05:36 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
well, you have to change your file names from .c to .cc/.cpp/.c++/.cxx/anything else your compiler takes. then you may need to include the headers required for c++ functions, and may need to change some of your existing includes if you are using the c++ namespace model. you may also find that you've forgotten to declare some std* functions, which is okay by c (although good compilers will give you a warning), but not c++. c also does not enforce type checking on function parameters (old c, anyway), so you may find that some of your functions complain about their arguments. some defined external variables may also need to use the "extern C" specifier. it is also generally considered bad form to mix allocations using "malloc" and "new".

generally, a well-written c program will 'port' with little to no problems. a poorly written one, relying on old quirks in the language and general poor programming, can be quite a challenge.
joe_bruin is offline   Reply With Quote
Old 05-26-2004, 03:33 AM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
...so i can then program OO.
In C you can program object oriented as well. Both C and C++ are weak OO languages.
But OO in C is different from C++.

It's more on how familiar you are with (modern) OO paradigms.
__________________
Valmont is offline   Reply With Quote
Old 05-26-2004, 07:38 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
thanks again joe and val.

i didn't know C could be programmed OO, .. but then i haven't really worked with it much at all besides this project.
__________________
Mike
sde is offline   Reply With Quote
Old 05-26-2004, 09:37 AM   #5 (permalink)
Blood Night
Registered User
 
Join Date: May 2004
Posts: 4
Blood Night is on a distinguished road
do you think that "struct" has the oo factor within it?
Blood Night is offline   Reply With Quote
Old 05-26-2004, 09:51 AM   #6 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
No single entity in C or C++ has the OO factor in it. But both of them offer a set entities wich enables OO. Both are suitable on a certain level for OO, but once again, notion and know how of OO is more important to master OO.
Merely using the features provided in an object oriented language doesn't mean one is automatically programming object oriented wise. Elements of it might be present, true that, but that hardly can't be the issue.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommend a good OOP book? Epsilon PHP 3 06-10-2004 09:03 AM
OOP with PHP sde PHP 2 08-01-2002 02:09 PM


All times are GMT -8. The time now is 04:27 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting