0

In the last chapter of my book we implemented a simplified version of the vector class

In the chapter I'm studying now we're implementing a simplified version of the string class ... which uses my version of the vector class (called Vec) to hold chars.

Str(const char* cp) {
		std::copy(cp, cp + std::strlen(cp), std::back_inserter(data));
	}

	template<class In> Str(In b, In e){
		std::copy(b, e, std::back_inserter(data));
	};

Given this two constructors where data is the name of a Vec<char>

The first constructor gives me a error message saying:
error C2039: 'reference' : is not a member of 'Vec<T>'
but the second one (which also uses back_inserter) doesn't give me this message.
Why is only one of them complaining? that really confused me

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mitrious
0

The second one doesn't complain because it hasn't been instantiated yet. If you call Str like so Str(cp, cp + strlen(cp)) then you would get that same error.

Edited by firstPerson: n/a

0

The second one doesn't complain because it hasn't been instantiated yet. If you call Str like so Str(cp, cp + strlen(cp)) then you would get that same error.

I see ... makes sense ... didn't think of that ... thx man!

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.