Guys,
Just want to know how to acess a method from a .h file in another .cpp file
Correct my code below show.
Ex:
// main.cpp
#include <iostream>
#include "inc/one.h"
using namespace std;
int main( )
{
School Tadd;
Tadd.AddTeacher(1);
return 0;
}
*********************************
//one.h
#ifndef ONE_H_INCLUDED
#define ONE_H_INCLUDED
using namespace std;
class School
{
public:
School();
void AddTeacher(int );
};
//constructor
School::School() {};
******************************
//one.cpp
#include "inc/one.h"
bool School::AddTeacher (int choice)
{
cout << "Adding a teacher \n";
return 0;
}
***********************
when i compile , i am getting the below error
In function main:
undefined reference to `School::AddTeacher(int)'
Build finished: 1 error
If i change it to bool also it wont work ..
Did you add 'one.cpp' to your project?