May 21, 2013 at 2:27pm UTC
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"
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
Last edited on May 21, 2013 at 2:30pm UTC
May 22, 2013 at 5:13am UTC
Thank for the reply .. but that is not the fix for it ... while posting i forgot to add void as a return type
May 22, 2013 at 6:06am UTC
try copying the code ,compile and see .. let me know ur results