Quantcast
Channel: Comments on: 7.7 — Default parameters
Viewing all articles
Browse latest Browse all 48

By: Avneet

$
0
0

Alex, is there any way to forward declare a function that has default pararmeters in it…?

[code]
#include <iostream>

void val(int, int);

int main()
{
    int value = 10;
    val(value);
    return 0;
}

void val(int nval, int val2 = 20)
{
    std::cout << nval << "\n";
    std::cout << val2 << "\n";
}

This program gives an error at line 8:

"Fire.cpp|8|error: too few arguments to function ‘void val(int, int)’|"

and if I remove an int, compiler says that it is unable to find a function with only 1 int parameter.


Viewing all articles
Browse latest Browse all 48

Trending Articles