cannot convert parameter
От: Аноним  
Дата: 06.12.05 18:38
Оценка:
#include <iostream>

using namespace std;

template <class T>
class Pointer
{
    private:
        T* value;
    public:
        Pointer(T* pointer)
        {
            value=pointer;
        }

        T* GetValue()
        {
            return value;
        }
};

class Int:public Pointer<int>
{
    public:
        int GetInt()
        {
            return *GetValue();
        }
};

int main(void)
{
    int* tmp=new int;
    *tmp=4;
    Int i(tmp); //error C2664: 'Int::Int' : cannot convert parameter 1 from 'int *' to 'const class Int &'
        //Reason: cannot convert from 'int *' to 'const class Int'
        //No constructor could take the source type, or constructor overload resolution was ambiguous
    cout<<i.GetInt();
    delete tmp;
    return 0;
}


В чём тут ошибка? pointer<int> intpointer(tmp) понимает, Int i(tmp), нет.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.