C++ error LNK1120 and LNK2019 unresolved externals

Hey guys, I am trying to execute method, which is in another class, from main. I got all three classes in header file. When running program it says :
Error 2 error LNK1120: 1 unresolved externals D:\Year 2\Semester 2\C++\Exercises\ArraySearch\Debug\ArraySearch.exe 1 1 ArraySearch

AND


Error 1 error LNK2019: unresolved external symbol "public: void __thiscall array::print(void)" (?print@array@@QAEXXZ) referenced in function _main D:\Year 2\Semester 2\C++\Exercises\ArraySearch\ArraySearch\arraytest.obj ArraySearch


I dont know what Im doing worng. Heres my code for array.cpp
1
2
3
4
5
6
7
8
#include "array.h"



void print()
{
	cout << "something";
}


Code for main.cpp

1
2
3
4
5
6
7
8
9
10
# include "array.h"


int main(void)
{
	array* a = new array();
	a->print();
	system("PAUSE");

} 


And code for header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef ARRAY_H
#define ARRAY_H
#include <iostream>
#include <cstdlib>
#include <cstring>


using namespace std;
class array
{

public:
	void print();
	
};
class arraytest 
{
	int main();
};

#endif 

I've removed all unecesary methods as they work. Please help me sort this problem out. Thank for your time in advance.
You haven't defined the print member of array. What you have defined is a free function print which is not related to the class array.

array.cpp:
1
2
3
4
5
6
#include "array.h"

void array::print()
{
    std::cout << "something" ;
}


Likewise with arraytest::main, although I don't see any reason for that class to exist at all. You should also probably avoid naming classes names which conflict with types in the std namespace (such as std::array) especially if you're going to put using namespace std; in header files. It would also be advisable not to put using directives such as that in header files.
Thank you cire, I'll have that in mind. Appreciate your help and patient with such a messy code ha ha
Topic archived. No new replies allowed.