a) Explain the difference between a function prototype and a function definition
ID: 3908826 • Letter: A
Question
a) Explain the difference between a function prototype and a function definition. b) What's a default constructor? How are an object's data members initialized if a class has only an implicitly defined default constructor? Explain the purpose of a data member. c) d) how a program could use class string without inserting a using directive e) Write a statement that uses list initialization to initialize an object of class Account which provides a constructor that receives an unsigned int, two strings, and a double to initialize accountNumber, firstName, lastName, and balance data members of a new object of the class. adble. nameExplanation / Answer
a) Function prototype tells the compiler the name, return type, and parameters of the function. Function definition is the actual declaration of the function. It includes the function body that defines what happens when the function is called.
b) Default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values. Data members are initialised using the default constructor, if the class only has a default constructor.
c) A data member contains values that are stored internally and which are unique to an object.
d) A program can use class string without inserting a using directive. On needs to simply qualify the names from std namespace; i.e. write std::string.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.