Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSix222

Posted 20 September 2013 - 12:59 PM

I'm having an issue with syntax and I was wondering if anyone could explain why the following code counts as a redefinition and doesn't work as expected?

int z;

template<class T>
void add(T x, T y) {
	z = x + y;
}

add<int>(100, 50); // Error C2365

int main() {

	cout << z << endl;

	return 0;
}

Thanks smile.png


#2Six222

Posted 20 September 2013 - 12:58 PM

I'm having an issue with syntax and I was wondering if anyone could explain why the following code counts as a redefinition and doesn't work as expected?

int z;

template<class T>
void add(T x, T y) {
	z = x + y;
}

add<int>(100, 50);

int main() {

	cout << z << endl;

	return 0;
}

Thanks smile.png


#1Six222

Posted 20 September 2013 - 12:58 PM

I'm having an issue with syntax and I was wondering if anyone could explain why the following code counts as a redefinition and doesn't work as expected?

int z;

template<class T>
void add(T x, T y) {
	z = x + y;
}

add<int>(100, 50);

int main() {

	cout << z << endl;

	system("PAUSE");
	return 0;
}

Thanks :)


PARTNERS