Defaults for Constructor

This is a discussion on Defaults for Constructor within the C# Programming forums, part of the General Programming Boards category; I read in C++ vs C# section C# does not provide defaults for constructors unlike C++ what does that mean?...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    99

    Defaults for Constructor

    I read in C++ vs C# section

    C# does not provide defaults for constructors unlike C++

    what does that mean?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You can add default values to contructors in C++

    Code:
    MyConstructor(int x = 0)
    {
    }
    
    MyConstructor m; //fine
    MyConstructor n(10); //fine
    As yor book says, doesnt work in C# though

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi-core affinity defaults
    By CodeMonkey in forum Tech Board
    Replies: 4
    Last Post: 12-08-2008, 02:47 PM
  2. Template Defaults
    By Cactus_Hugger in forum C++ Programming
    Replies: 4
    Last Post: 07-21-2008, 01:25 AM
  3. Replies: 3
    Last Post: 10-15-2007, 12:50 PM
  4. Unix - Checking defaults
    By john513 in forum Networking/Device Communication
    Replies: 1
    Last Post: 10-31-2005, 07:07 PM
  5. constructor invocation---other than the defaults?
    By lydiapeter in forum C++ Programming
    Replies: 8
    Last Post: 09-05-2005, 09:49 PM

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