-2

Here is a modified code from geeks for geeks.

   #include<iostream>
   using namespace std;

   class Test {
    int value;
   public:
       Test(int v = 0) {value = v;}
    int getValue() {return value;} 
   };

   int main() {
       Test t(20);
       cout<<t.getValue();
       return 0;
   }

What does parameter in function Test(int v=0) means?

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
Satender
  • 117
  • 1
  • 2
  • 9
  • Or https://stackoverflow.com/questions/17961277/assigning-parameter-value-in-function-declaration – Tas Jul 21 '17 at 03:47

1 Answers1

1

That is default value for v parameter, which is the v variable will use that value if there is no value passed

azisuazusa
  • 317
  • 1
  • 12