diff --git a/Header Files/header.cpp b/Header Files/header.cpp new file mode 100644 index 0000000..829ff8f --- /dev/null +++ b/Header Files/header.cpp @@ -0,0 +1,11 @@ +#include +#include "header.h" // this is the header file I have made + +using namespace std; +using namespace Header; // made a namespace from the header file and now accessing it + +int main() { + MyHeader mh; // taking the class and defining an object + cout << mh.name << endl; // prints "this is my header name" + cout << mh.age << endl; // prints "19" +} \ No newline at end of file diff --git a/Header Files/header.h b/Header Files/header.h new file mode 100644 index 0000000..a4779a2 --- /dev/null +++ b/Header Files/header.h @@ -0,0 +1,16 @@ +#pragma once // ensures that the header file is only included once and not all the time during compiling + +#ifndef HEADER // if not defined +#define HEADER // define HEADER + +#include + +namespace Header { // defines the header for the main file to "using namespace " stuff + class MyHeader { // define header + public: // public access identifier + std::string name = "this is my header name"; // makes a variable called name + int age = 19; // makes a variable assigned to int 19 + }; +} + +#endif // end the ifndef at line 3 \ No newline at end of file