Hard to explain -,-.

This is a discussion on Hard to explain -,-. within the C++ Programming forums, part of the General Programming Boards category; Ok, I havent written the code yet, but I'm wondering, is it possible to leave a default value for something? ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Hard to explain -,-.

    Ok, I havent written the code yet, but I'm wondering, is it possible to leave a default value for something?

    IE:

    Code:
    void 2012(int n) {
     #define int nDEFAULT 1
     cout << n; //If you specify nothing for n, rather than 0, it should
     //say "1".
    }
    Not real code, but do you get the point?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,437
    Sure, like this
    Code:
    #include <iostream>
    using namespace std;
    
    void foo ( int n = 1 );
    
    int main ( ) {
      foo ( ); // use default
      foo ( 2 );
      return 0;
    }
    
    void foo ( int n ) {
      cout << n << endl;
    }

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    *Kicks himself in the face". I need to get out of the habbit of thinking stupidly -,-.

    Tyvm, you just saved my life XD.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. which hard drive to buy ? UATA or SATA
    By gemini_shooter in forum Tech Board
    Replies: 10
    Last Post: 08-24-2005, 08:16 PM
  2. how to read hard disk serial number
    By toufiq_raja in forum C Programming
    Replies: 4
    Last Post: 08-18-2005, 10:08 PM
  3. is this old hard drive any good?
    By Pyroteh in forum Tech Board
    Replies: 11
    Last Post: 07-16-2005, 08:34 PM
  4. Strange hard disk
    By GanglyLamb in forum Tech Board
    Replies: 20
    Last Post: 03-01-2003, 03:05 AM
  5. Failing Hard Drive
    By RoD in forum Tech Board
    Replies: 10
    Last Post: 02-18-2003, 07:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21