answersLogoWhite

0


Best Answer

// declaration:

return_type function_name([argument_type_1[=value][, argument_type_2[=value][, ...]]]);

// definition (function signature must match declaration):

return_type function_name([argument_type_1 argument_name_1[, argument_type_2 argument_name_2[, ...]]])

{

// implementation

}

In the case of separate declaration/definition, the definition file must include the file that contains the declaration unless they are both in the same file. If the function is a template function, both the declaration and the definition must be visible to the compiler BEFORE it can be used (thus they must both be in the same file). For all other functions other than inline expanded functions, only the declaration need be visible.

Note that the definition is also a declaration, however default values must be omitted and all arguments must be named. The declaration arguments may also be named but they needn't match those in the definition (the definition names are the ones actually used).

Alternatively:

// combined declaration and definition:

return_type function_name([argument_type_1 argument_name_1[=value][, argument_type_2 argument_name_2[=value][, ...]]])

{

// implementation

}

Functions that are defined in the declaration are impicitly inline expanded. Functions that are defined separately must be prepended with the inline keyword in the definition, and the definition must be visible to the compiler BEFORE the function can be used.

Functions that do not return a value must return void. If any other return type is specified, the function must explicitly return that type via all return paths. The main function must return an int, however return(0) is implied if not specified in the final statement.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a function in Turbo C Plus Plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

What is the differentiate of turbo c from turbo c plus plus?

Turbo C compiles c source. turbo c++ compiles c++ source code.


Write a C plus plus function that print a triangle of stars?

Write a function that print a triangle of stars.


How the turbo c plus plus use in the computer?

How the turbo c plus plus use what in the computer.


Who develop the turbo c plus plus?

The company Borland developed Turbo C++.


Is there any difference between turbo c and c plus plus?

turbo c is a compiler and c++ is a programming language.


What is turbo c plus plus?

Turbo C++ is Borland's integrated development environment (IDE).


To develop a taj mahal using c-language programming in turbo c plus plus?

turbo c


How can you write your name on c plus plus turbo v3.0?

#include<iostream> int main() { std::cout << "Your name"; }


How do you rectify the waring is function should return a value in turbo c plus plus?

By returning a value. Or using type 'void'.


Differentiate C plus plus and Turbo C?

Turbo C is a software where C or C++ programming environment resides in.But C++ is itself a programming language.


How do you write a programm in c plus plus without using function main?

I don't think its possible. Every C++ program must at least have the main function.


Which header file is used for gotoxy function in turbo c plus plus?

It's in conio.h, but don't use gotoxy. Use SetCursorPosition() instead.