Compiling .inl in Visual Studio 2010

I am trying to implement a very simple code in Visual Studio 2010.

-------------File Name: BDclass.h------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

#ifndef BDCLASS_H
#define BDCLASS_H

#include <iostream>
#include <vector>
#include <string>

class test
{
public:
	void print();
};

#include "BDclass.inl"
#endif


------------------File Name: BDClass.inl-----------------
1
2
3
4
void test::print()
{
	std::cout<<"in the class"<<std::endl;
}


----------------------File Name: Main File.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "BDclass.h"
using namespace std;

int main()
{
	test t1;

	t1.print();

	cout<<"I am in main"<<endl;
	
	system("pause");
	return 0;
}


These are the errors I get:
error C2653: 'test' : is not a class or namespace name
error C2039: 'cout' : is not a member of 'std'
etc.,

If I do not use the .inl file at all the code runs fine. Where am I screwing up?
Are you including the .inl in the project?
Yes I am.

If I do not include it in Project, how else should I make it work?

The tree looks as:
Header file - BDclass.h

Resource file: BDclass.inl

Source File: Main File.cpp

When I first created the project, I added files to the sections Header Files, Resource Files and Source Files.

Is there a correct way to do this?
If you include a file in the project, the IDE will interpret what to use to compile it based on the extension. For example, headers aren't compiled, C files are compiled with the C compiler, C++ files are compiled with the C++ compiler, and resource files are compiled with the resource compiler. In this case, DBclass.inl is being interpreted as a C++ file and compiled as a translation unit. If you want to compile it this way, include BDclass.h in it (you'll have to remove line 15 from the header or you'll produce a mutual inclusion). Otherwise, remove DBclass.inl from the project.
@helios
I implemented both methods mentioned by you and I get "unresolved external" error. I am using Visual Studio 2010. Is there some known issues with it as earlier I was using Visual Studio 2008 and it ran my code fine as I had typed in original message.

If I exclude line 15, how would the BDclass.h ever know where to look for definition of print() function?
I think there is an error in Visual Studio 2010 because of which my program would not compile. I saw at least one another programmer with similar problem on Microsoft forum and he did not have a concrete solution either. So, I have switched back to Visual Studio 2008. The code works fine.
Topic archived. No new replies allowed.