Reputation: 111
I'm working on a project my professor gave me. One of the functions that I have to implement uses a parameter passed in as such. Normally I am used to using parameters with variables.
Instruction as to what the function is supposed to do:
binMinHeap<Type>::binMinHeap(int capacity)
-default constructor that sets
this->capacity
with the parameter passed in, sets the size accordingly, and allocates an array to heapArray
He also provides the piece below and I am not supposed to edit any of the functions or parameters.
class binMinHeap
{
public:
binMinHeap(int = 10);
...
}
As an example, normally if the function was given such as binMinHead(int capactity)
, I would understand to do something such as
binMinHeap(int capacity= 10){
something = capacity;
...
}
but how do I access the parameter of just "int=10"?
Upvotes: 1
Views: 1079
Reputation: 172894
but how do I access the parameter of just "int=10"?
int = 10
declares an unnamed parameter with type int
and default argument 10
. If you want to use it, you need to specify the name for it. In the declaration the name is not used and not required, you can specify the name in the definition.
class binMinHeap
{
public:
binMinHeap(int = 10); // declaration
};
// definition
binMinHeap::binMinHeap(int capacity) {
something = capacity;
...
}
Upvotes: 1