Multiple file access

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


the problem is that the prototype doesn't match:

1
2
3
4
5
6
class School
{
void AddTeacher(int );
};

bool School::AddTeacher (int choice)
If i change it to bool also it wont work ..
Did you add 'one.cpp' to your project?
Topic archived. No new replies allowed.