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

Recommended Answers

All 2 Replies

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.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.