#include <vector>
struct A {int a;};
struct B : public A {char b;};
int main()
{
B b;
typedef std::pair<A*, A*> MyPair;
std::vector<MyPair> v;
v.push_back(std::make_pair(&b, &b)); //compiler error should be here(pair<B*,B*>)
return 0;
}
Non capisco perché questo compila (forse qualcuno può gentilmente fornire spiegazione dettagliata? E 'qualcosa legato al nome di look-up?C++ template fusione con le classi derivate
Btw, su Solaris, SunStudio12 esso non compila: error : formal argument x of type const std::pair<A*, A*> & in call to std::vector<std::pair<A*,A*> >::push_back(const std::pair<A*, A*> &) is being passed std::pair<B*, B*>
Quel modello di struttura sopra non sta davvero facendo molto è? – BenG
@BennyG: Ha sentito dei problemi nel quartiere e ha deciso di venire a dare un'occhiata. –
scusate, cancellato – yurec