C++/C# 函數參數 預設值
C++/C# 函數參數 預設值
#include <iostream>
using namespace std;
void do_something(int n = 22)
{
std::cout << n << std::endl;
}
int main()
{
cout << “Hello World” << endl;
do_something(11);
do_something();
return 0;
}
///////////////////////////////////////////////////////////
using System.IO;//C#
using System;
class Program
{
static void do_something(int n = 22)
{
Console.WriteLine(“n=”+n);
}
static void Main()
{
Console.WriteLine(“Hello, World!”);
do_something(11);
do_something();
}
}