#include <iostream>
#include <string>
std::string* concat_print_strings(std::string* pStr1, std::string* pStr2 )
{
std::string * strResult = new std::string( *pStr1 );
strResult->append( *pStr2 );
std::cout << strResult->c_str() << std::endl;
return( strResult ); }
int main()
{
std::string str1 = "This is a string.";
std::string str2 = " And this is another string.";
std::string* pStr = concat_print_strings( &str1, &str2 );
delete( pStr );
pStr = NULL;
return( 0 ); }
scanf() is an input function which reads input from the standard input devices such as keyboard. Syntax: scanf("Control Character",address_list); where control character is a sequence of one or more character such as %d,%f,%lf,%lld. Address list specifies the variables, pointers etc. e.g. scanf("%d",&num);
Yes. Examples can be found in stdio.h
No. But avoiding unnecessary duplication of data does.
// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);
By reference. The name of the string is converted to a pointer (in C/C++) and given to the function as the address of the first element. (In Java, all objects are passed by reference, and there are no pointers.)
A virtual function table is a table of pointers to functions.
scanf() is an input function which reads input from the standard input devices such as keyboard. Syntax: scanf("Control Character",address_list); where control character is a sequence of one or more character such as %d,%f,%lf,%lld. Address list specifies the variables, pointers etc. e.g. scanf("%d",&num);
Just as pointers can point to variables, pointers can also point to functions. Thus you can pass function pointers to functions. In so doing, you can alter the behaviour of the function by having it call dynamically call arbitrary functions rather than just preset functions.
Yes. Examples can be found in stdio.h
Function Pointers are basically used when we want to select a function which is to be used dynamically at run time.
i don't know ask someone else
No. But avoiding unnecessary duplication of data does.
Because you can produce fast and efficient code. Function arguments are passed "by value", and so you can't change the original value of the argument, but if you use pointers, you can.
function-these are self contained block of statements to solve a particular task whereas pointers are defined as the variable which stores the address of another variable
No.
Like any other value/variable -- nothing special.
// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);