prototype for function

Posted on 2006-05-06
Last Modified: 2010-04-01
another question from review study guide:

In C/C++, the prototype for a function that has no arguments may or may not contain the keyword void:
     int f (void);
     int f( );
a) In C, what is the difference (if any) between using the word void and not using it?
b) Repeat part (a) for C++
Question by:shahrine99
    LVL 45

    Accepted Solution

    Hi shahrine99,

    > a) In C, what is the difference (if any) between using the word void
    > and not using it?
    First case means that function accepts no arguments ... while second means that function arguments are unspecified .. compiler wont be able to generate any type mismatch warnings/errors for the second case

    > b) Repeat part (a) for C++
    Due to strict type checking, both declarations are equivalent in C++


    Author Comment

    thanks sunny! but another thing... C and C++ are equivalent?
    LVL 45

    Expert Comment

    > C and C++ are equivalent?
    No ... C++ is object oriented ... C is procedural in approach
    They are similar but yet quite different

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Article by: SunnyDark
    This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now