Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Problem z szablonami

Ostatnio zmodyfikowano 2014-01-12 13:36
Autor Wiadomość
Mig
Temat założony przez niniejszego użytkownika
Problem z szablonami
» 2014-01-12 12:50:40
Siemka

Podczas pisania DLL natrafiłem na problem mianowicie mam taki kod dll :
C/C++
#pragma once
#include "Export.h"
#include "Event.h"
#include <list>
template < typename EVENT >
class GUI_API std::list < EVENT, std::allocator < EVENT >>;


namespace mig
{
   
    template < typename EVENT >
    class GUI_API Collection_Event
        : public Event
    {
    public:
        Collection_Event();
        Collection_Event( Collection_Event && obj );
        Collection_Event( const Collection_Event & obj );
       
        Collection_Event & operator =( Collection_Event && obj );
        Collection_Event & operator =( const Collection_Event & obj );
       
        virtual ~Collection_Event();
        virtual void Execute() const;
        virtual void AddEvent( EVENT event );
        virtual void RemoveEvent( EVENT event );
       
    private:
        std::list < EVENT > _events;
       
    };
   
}
A chce się posługiwać tą klasą np. w ten sposób :
PLIK : main.cpp
C/C++
#include "stdafx.h"
#include <iostream>
#include "MIGUI.h"

class My_Event
    : public mig::Event
{
public:
    My_Event() { std::cout << " KONSTRUKTOR " << std::endl; }
    ~My_Event() { std::cout << " DESTRUKTOR" << std::endl; }
   
    void Execute() const { std::cout << "Execute" << std::endl; }
   
};


int _tmain( int argc, _TCHAR * argv[] )
{
    mig::Event * event = new My_Event();
    mig::Event * event2 = new My_Event();
    mig::Event * event3 = new My_Event();
    mig::Event * event4 = new My_Event();
    mig::Event * event5 = new My_Event();
   
    mig::Collection_Event < mig::Event *> collection;
    collection.Execute();
    collection.AddEvent( event );
    collection.AddEvent( event2 );
    collection.AddEvent( event3 );
    collection.AddEvent( event4 );
    collection.AddEvent( event5 );
    collection.Execute();
   
   
   
    system( "PAUSE" );
    return 0;
}
Problem w tym że dostaję taki błąd :
error C2079: 'mig::Collection_Event<mig::Event *>::_events' uses undefined class 'std::list<EVENT,std::allocator<_Ty>>'
1>          with
1>          [
1>              EVENT=mig::Event *
1>  ,            _Ty=mig::Event *
1>          ]
W jaki sposób mam temu zaradzić w czym tkwi błąd ?
P-101923
pekfos
» 2014-01-12 13:27:24
C/C++
template < typename EVENT >
class GUI_API std::list < EVENT, std::allocator < EVENT >>;
Usuń to.
P-101927
Mig
Temat założony przez niniejszego użytkownika
» 2014-01-12 13:36:34
Jak to usunę to nadal będzie błąd a nawet parę dodatkowych oraz będą informacje kompilatora dodatkowo takie :

warning C4251: 'mig::Collection_Event<EVENT>::_events' : class 'std::list<EVENT,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'mig::Collection_Event<EVENT>

 Dzięki tej deklaracji nie ma tych błędów.

Błąd który podałem dotyczy linii 29 ( definicji listy w klasie )
P-101929
« 1 »
  Strona 1 z 1