Template type argument issue

Hi everyone,

Now i don't quite understand what's going on, maybe i'm just over thinking this a bit but I keep running into this error from a template I've created, it's very simple.

1
2
3
4
5
6
7
8
template <typename T>
class vector2d {
	T X, Y;
public:
	vector2d(T x, T y) { X=x; Y=y; }
	~vector2d();
	T area();
};


When i try to use the vector2d like such...
 
vector2d<int> test(2,2);


It gives me an error in the arguments for test(int, int) saying that the type is not specified.

I've never really got too into using templates until just now. Help would be much appreciated ^^.

Now the strange part is that it will not give me any issues if I utilize this method.
 
vector2d<int> test = vector2d<int>(2, 2);



I just tried starting a fresh project with a test template and this is the code for it..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

template <class T>
class vector2d {
public:
	T X, Y;
	vector2d(T x, T y) { X=x; Y=y; }
};

int main() {
	vector2d<int> test(2, 4);
	printf("%d %d", test.X, test.Y);
	std::getchar();
	return 0;
}


This seems to work just fine now, i'm not sure what's going on here?? is it because in the non-working file it's inside a namespace? or it's because it's setup as a Dll? i have no clue >_< losing me mind!!!!!!! :)
Last edited on
Can you post the exact error message?
 
	2	IntelliSense: expected a type specifier	c:\Users\admin\Vector.h	51	24	Vector
Intellisense errors are not compilation errors. It just means that your IDE is confused - if you use Rebuild Solution the problems should go away. if not, close the project and delete the intellisense database file so it is regenerated.
Thanks for the response y'all, It still seems to be confused but I'll have to check into it tomorrow. Thank y'all again for responding and trying though!

edit:
So i just ended up removing the line of code and trying again, now it works -_-... Thanks a bunch guys!
Last edited on
Topic archived. No new replies allowed.