C++ solution

Topics: C, Java, Data type Pages: 2 (459 words) Published: May 20, 2014
(i) Conversion from Class to Basic Type: We know that conversion from a basic to class type can be easily done with the help of constructors. The conversion from class to basic type is indeed not that easy as it cannot be done using constructors. for this conversion we need to define an overloaded casting operator. This is usually referred to as a conversion function. The syntax for this is as follows:

operator typename(){….}

The above function shall convert a class type data to typename. A conversion function must follow the following 3 rules:
a. It cannot have a return type
b. It has to be declared inside a class.
c. It cannot have any arguments.

(ii)File pointers: we need to have file pointers viz. input pointer and output pointer. File pointers are required in order to navigate through the file while reading or writing. There are certain default actions of the input and the output pointer. When we open a file in read only mode, the input pointer is by default set at the beginning. When we open a file in write only mode, the existing contents are deleted and the file pointer is attached in the beginning. C++ also provides us with the facility to control the file pointer by ourselves. For this, the following functions are supported by stream classes: seekg(), seekp(), tellg(), tellp().

(iii) Function prototyping is used to describe the details of the function. It tells the compiler about the number of arguments, the type of arguments, and the type of the return values. It some what provides the compiler with a template that is used when declaring and defining a function. When a function is invoked, the compiler carries out the matching process in which it matches the declaration of the function with the arguments passed and the return type. In C++, function prototype was made compulsory but ANSI C makes it optional. The syntax is as follows:

type function-name(argument-list);

int func(int a, int b, int c);

Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Computer Guess Paper for C++ and Java
  • Essay on C Programming for Beginers
  • C++ Notes Essay
  • C++ Learning Essay
  • avast and c++ Essay
  • Essay about A Beginner's Guide to C++
  • Essay about C Language Interviw Questions
  • C LANGUAGE Essay

Become a StudyMode Member

Sign Up - It's Free