A constructor like a member function can have default arguments. The default arguments should be declared at the end of the parameters list. Following program demonstrates a constructor with default arguments: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #include <iostream> using namespace std; class Student { private: string name; string regdno; int age; string branch; int *marks; public: Student(string branch, int n = 4) //Constructor { marks =
The post How to create a constructor with Default Arguments appeared first on Coding Security.
How to create a constructor with Default Arguments
read more
Tidak ada komentar:
Posting Komentar