View Single Post
Old 09-09-2004, 04:19 PM   #1 (permalink)
KnifeMissile
 
KnifeMissile's Avatar
 
Location: Waterloo, Ontario
[C++] struct typing issues

Why is it that this code (correctly, in my opinion) fails to compile:
Code:
struct Foo {
	int value;
};

struct Bar {
	int value;
};

Foo foo;
Bar bar = foo;
Yet this code compiles just fine.
Code:
template<typename T> struct Value {
	T value;
};

typedef Value<int> Foo;
typedef Value<int> Bar;

Foo foo;
Bar bar = foo;
Is there anyway to get struct typing behaviour with templates? Why does C++ behave this way? If it helps, I'm using gcc 3.2.3
Thanks!
KnifeMissile is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73