When building the program I get the following error: undefined reference to `Atom:: DoBCC(float, int, int, int)'. What am I doing wrong? Thanks in advance.
main.cpp
Code:
#include <iostream>
#include "Atom.h"
using std::cout;
using std::cin;
using std::endl;
int main ()
{
int latticeType;
int dimX, dimY, dimZ; // number of translated lattices along each axis
float d; // lattice parameter
Atom myAtom; // object of class Atom
cout << "Please choose the crystal lattice." << endl;
cout << "Type 1 for BCC, 2 for FCC, and 3 for HCP:" << endl;
cin >> latticeType; // read lattice type
cout << "Please enter lattice parameter:" << endl;
cin >> d;
cout << "Please enter the number of translated lattices along X axis:" << endl;
cin >> dimX;
cout << "Please enter the number of translated lattices along Y axis:" << endl;
cin >> dimY;
cout << "Please enter the number of translated lattices along Z axis:" << endl;
cin >> dimZ;
if (latticeType==1) myAtom.DoBCC ( d, dimX, dimY, dimZ ); // if 1, create BCC lattice
else
{
cout << "Invalid value" << endl;
return 0;
}
return 0;
}
Atom.h
Code:
class Atom
{
public:
void DoBCC ( float, int, int, int );
private:
float x, y, z;
};
Atom.cpp
Code:
#include <iostream>
#include "Atom.h"
using std::cout;
using std::cin;
using std::endl;
typedef class Atom AtomType;
void Atom::DoBCC ( float d, int dimX, int dimY, int dimZ ) // beginning of the DoBCC function
{
float a = d; // lattice parameter
int Lx = dimX;
int Ly = dimY;
int Lz = dimZ; // number of translated lattices along each axis
// from now on I work with a, Lx, Ly, Lz variables
} // end of the DoBCC function