Adapted from: “Object-Oriented Programming Using C++” by Ira Pohl (Addison- Wesley)
Program that demonstrates function invocations in C++¶
// Ring the bell using '\a' literal for the alarm.
#include <iostream>
const char BELL = '\a';
void ring()
{
std::cout << BELL;
std::cout << "Hello from function ring!" << std::endl;
}
int main()
{
ring();
}Compile and Exectute the Program¶
The above program is compiled and run using Gnu Compiler Collection (g++):
import os
root_dir = os.getcwd()code_dir = root_dir + "/" + "Cpp_Code/Chapter_3_1_1_Function_Invocation"ch_dir_stat = os.chdir(code_dir)build_command = os.system("g++ bell.cpp -w -o in_the_bell")exec_status = os.system("./in_the_bell")Hello from function ring!