Intro to PreProcessor Directives and include Directive
This video tutorial introduces you to the pre-processor directives in c++ and also explains the include pre-processor directive in detail.
You are gonna learn what are pre-processor directives, how to use include pre-processor directive, how to include a c++ source file to your program using include pre-processor directive in detail with example.
source code for this tutorial
create a c++ class file and name it "person_class.cpp" and write the source code below
class Person{
string name;
int age;
public:
Person(string name,int age){
this->name = name;
this->age = age;
}
void display(){
cout << "am "<<name<<" and i am "<<age<<" years old"<<endl;
}
};
In the "main.cpp" write the following code
#include <iostream>
using namespace std;
#include "person_class.cpp"
int main()
{
Person anil("anil",24);
anil.display();
return 0;
}