0

Hello, i got in trouble once again, this time in excersise 14-4 in Accelerated C++.
When i compile i get an error message that you probably know.

fatal error LNK1169: one or more multiply defined symbols found

Can anyone see what i am missing here? Edit: This is all in the .hpp file with the class that uses the functions.

template<class T>
T* clone(const T* tp)
{
	return tp->clone();
}

template<>
std::vector<char>* clone(const std::vector<char>* vp)
{
	return new std::vector<char>(*vp);
}

Edited by Andreas5: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Andreas5
0

The template functions worked as they should.
What i found was causing the problem was that i had included a .hpp file with a template function in a .cpp file:

#ifndef GUARD_Str3_info
#define GUARD_Str3_info
class Str3 {               //Str3.hpp
public:
	template<class In> Str3(In b, In e): data(new vector<char>) {
		std::copy(b, e, std::back_inserter(*data));
#include "stdafx.h"
#include "Str3.hpp"
//...                       //Str3.cpp

Do you know why i can not do this? I use Visual C++ 2008.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.