1.
#include <iostream>

void myfunc(void) {
        std::cout << "myfunc(void) called" << std::endl;
}
void myfunc(char c) {
        std::cout << "myfunc(char c) called" << std::endl;
}
void myfunc(int a, int b) {
        std::cout << "myfunc(int a, int b) called" << std::endl;
}

int main(void) {
        myfunc();
        myfunc('A');
        myfunc(12, 13);
        return 0;
}

myfunc(void) called
myfunc(char c) called
myfunc(int a, int b) called



2.
#include <iostream>

int adder(int num1 = 1, int num2 = 3) {
        return num1 + num2;
}

int main(void) {
        std::cout << adder() << std::endl;
        std::cout << adder(5) << std::endl;
        std::cout << adder(8, 5) << std::endl;
        return 0;
}

4
8
13

'Programming > C++' 카테고리의 다른 글

표준입출력  (0) 2011.04.08

+ Recent posts