Languages [TCS Placement]: Sample Questions 129 - 130 of 131

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 129

Question

MCQ▾

Which of the following cannot be friend?

Choices

Choice (4)

a.

Function

b.

Operator function

c.

Class

d.

Object

Answer

d.

Explanation

  • An object cannot be friend.
  • An object is an instance of a Class.
  • When a class is defined, no memory is allocated but when it is instantiated (i.e.. an object is created) memory is allocated.
  • “Friend” is a compile time construct while “Objects” exist at run time.
  • A class is defined in C ++ using keyword class followed by the name of class.
  • When a class is defined, only the specification for the object is defined; no memory or storage is allocated. To use the data and access functions defined in the class objects have to be created.
  • Syntax: ClassName ObjectName;
Given the Image is Define the Class and Object Example

Question 130

Edit

Write in Short

Short Answer▾

What could be the problem if a valid function name such as tolower () is being reported by the c compiler as undefined?

Explanation

  • Probable reason behind this error is that the header file for that function was not included at the top of the program.
  • Header files contain the definition and prototype for functions and commands used in a C program.
  • For “tolower () ” , the code “#include < ctype. h >” must be present at the beginning of the program.

Developed by: