Thread: declaring a parameter type without naming it?

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    declaring a parameter type without naming it?

    say I have:

    Code:
    void funcLookup(char * ){
    
    }

    is this okay in C++?

    the parameter is without a name

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Yes, but why would you want to? What's the point of having a parameter if you don't plan on using it?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Placeholder, if you later plan to start using it (e.g for a dummy function that is not implemented yet)?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That or you need to implement some sort of callback function yet have no reason to use the parameter function and hate those stupid warnings about unused parameter arguments.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Or you override a virtual function that has parameters you don't need.
    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

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quite possible. You just will not be able to use that parameter in the function, so do it only to avoid warnings.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  2. maximum range for declaring a array of register type
    By anjana in forum C Programming
    Replies: 1
    Last Post: 05-24-2007, 05:42 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. cannot start a parameter declaration
    By Dark Nemesis in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2005, 02:09 PM
  5. Replies: 1
    Last Post: 05-18-2003, 05:10 PM