Constructors With Defaut Arguments
Code:
#include<iostream>
using namespace std;
class simple{
int data1;
int data2;
public:
simple(int a , int b=9){ //b=9 is default arguments here
a=data1;
b=data2;
}
void printdata(){
cout<<" The val is " <<data1<< "and " <<data2<<endl;
}
};
int main(){
simple s(12);
s.printdata();
return 0;
}