Bonjour,
Un bout de code très simple et que je n'arrive pas à compiler sous visual C++ Express.
Pourriez vous m'éclairer?
en vous remerciant d'avance.
Voici l'erreur que le compilateur me renvoie.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 1>main.obj : error LNK2019: symbole externe non résolu "public: virtual __thiscall SimplePropertySet<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double>::~SimplePropertySet<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double>(void)" (??1?$SimplePropertySet@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@N@@UAE@XZ) référencé dans la fonction _main 1>main.obj : error LNK2019: symbole externe non résolu "public: __thiscall SimplePropertySet<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double>::SimplePropertySet<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$SimplePropertySet@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@N@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) référencé dans la fonction _main 1>C:\Users\younes\Documents\Visual Studio 2008\Projects\testProperty\Debug\testProperty.exe : fatal error LNK1120: 2 externes non résolus
SimplePropertySet.hpp
SimplePropertySet.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <list> #include <string> #include <set> using namespace std; template <class N, class V> class SimplePropertySet { private: N nam; // The name of the set public: // Constructors and destructor SimplePropertySet(); // Default constructor SimplePropertySet(const N& name); // Named property set SimplePropertySet(const SimplePropertySet<N,V>& source); // Copy constructor virtual ~SimplePropertySet(); // Destructor };
Main.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include "SimplePropertySet.hpp" template <class N, class V> SimplePropertySet<N,V>::SimplePropertySet() { // Default constructor nam = N(); } template <class N, class V> SimplePropertySet<N,V>::SimplePropertySet(const N& name) { // Named property set nam = name; } template <class N, class V> SimplePropertySet<N,V>::SimplePropertySet(const SimplePropertySet<N,V>& source) { // Copy constructor nam = source.nam; } template <class N, class V> SimplePropertySet<N,V>::~SimplePropertySet() { // Destructor }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 #include "SimplePropertySet.hpp" #include <iostream> using namespace std; int main() { SimplePropertySet<string, double> input("Strike"); }
Partager