C++ Function Passing Arguments Question

Introduction

Write a program which has a function of type void called custommessage.

The function accepts one parameter by reference to const of type std::string and outputs a custom message on the standard output using that parameter's value.

Invoke the function in main with a local string.

You can use the following code structure.

#include <iostream> 

int main() 
{ 
    //your code here
} 


#include <iostream> 
#include <string> 

void custommessage(const std::string& message) 
{ 
    std::cout << "The string argument you used is: " << message; 
} 

int main() 
{ 
    std::string mymessage = "My Custom Message."; 
    custommessage(mymessage); 
} 



PreviousNext

Related