Mention the ways in which parameterized can be invoked. Give an example of each.



Mention the ways in which parameterized can be invoked. Give an example of each...

Answer / Lalit Kumar Saini

Parameterized functions or classes can be invoked in C++ in three ways: 1) Default Argument: When no argument is provided for a parameter that has a default value. Example: void greet(string name = 'World') { cout << 'Hello, ' << name << 'n'; } 2) Directly Providing Arguments: When specific arguments are provided to the function or class constructor. Example: vector<int> v(5); 3) Using Initializer Lists: When an initializer list is used to initialize a container. Example: vector<int> v = {1, 2, 3, 4, 5};

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Can you overload the operator+ for short integers?

1 Answers  


Is java based off c++?

1 Answers  


What is rtti in c++?

1 Answers  


Difference between overloading vs. Overriding

1 Answers  


What is volatile and pragma? When they are used?

1 Answers  


What are vtable and vptr?

1 Answers  


How do you decide which integer type to use?

1 Answers  


Explain virtual class?

1 Answers  


What is the main use of c++?

1 Answers  


What is the identity function in c++? How is it useful?

1 Answers  


What is a rooted hierarchy?

1 Answers  


give me an example for testing a program showing the test path .show how the test is important and complex.

1 Answers   TCS,


Categories