C++ Header and Source Files Question

Introduction

Write a program that declares an arbitrary function in a header file.

The header file is called myheader.

h Define this function inside the main program source file called source.cpp.

The main function is also located inside a source.cpp file.

Include the header into our source file and invoke the function.

myheader.h:

void myfunction();  //function declaration 

source.cpp:



#include "myheader.h" //include the header 
#include <iostream> 

int main() 
{ 
    myfunction(); 
} 

// function definition 
void myfunction() 
{ 
    std::cout << "Hello World from multiple files."; 
} 



PreviousNext

Related