Thread: Possible to create methods for data in structs?

  1. #16
    Registered User
    Join Date
    Dec 2004
    Posts
    35
    Quote Originally Posted by Dave_Sinkula
    >
    Or in C++ you could use what you had.
    well that sounds rather appealing...
    Quote Originally Posted by Dave_Sinkula
    >
    [edit]By the way, this
    Code:
       diffuser diff = {zeroEnergy};
    zeroed out those variables.
    then perhaps I should look into that way of doing it... or perhaps I am looking to hard to save myself 2 extra lines of code that overall probably keep things simpler.

    is there any situation in which a C++ compiler would complain about anything that the C compiler didn't have a problem with?

    ie should g++ -lm -lncurses -o dmc dmc.c ever complain if gcc -lm -lncurses -o dmc dmc.c doesn't?

    <edit>
    I wonder how hard it would be to write a textfield (like the one i am writing in) that is modal and supports some ViM commands... AND lets you use tab
    </edit>
    Last edited by eccles; 12-11-2004 at 12:27 AM.
    VIM + gcc + beer... does life get any better?

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    There are some things that are allowed in C that don't work in C++. Functions with an implicit return type, for example, or passing any amount of parameters to a function with an empty argument list. Old-style parameter lists are also disallowed in C++. (Not that you often see them - the only working piece of code I know that uses them is the zlib library.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    Registered User
    Join Date
    Dec 2004
    Posts
    35
    so do you have any thoughts then on the relative virtues of C/C++ in scientific computing applications?
    VIM + gcc + beer... does life get any better?

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Often, C will be a little faster. Not always. C++ usually allows better modeling of the problem, thus making implementation simpler. In general, C++ requires a little less code to do the same thing.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #20
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    C will generally operate at a lower level then C++. Meaning that it will use fewer function calls and less memory then C++. The speed issue really depends on the program and for the most part is a non issue.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multidimentional structs + memcpy() == FAIL
    By Viper187 in forum C Programming
    Replies: 8
    Last Post: 06-18-2008, 02:46 AM
  2. Turn Based Stradegy System Methods
    By TylerMoyer in forum Game Programming
    Replies: 2
    Last Post: 07-30-2007, 10:45 PM
  3. How to create a file association program?
    By eShain in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2006, 12:15 PM
  4. Cannot create MDI Client Win
    By JaWiB in forum Windows Programming
    Replies: 1
    Last Post: 10-31-2005, 10:05 PM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM