Hi Jedong,
Humm... You may have forgot that in C++, the STL container are supposed to be in the std namespace. So when doing:
#include <vector>
you then have to refer to the vector as
std::vector<double>
Or use (to avoid surprising user of your header files do that ONLY in a source file)
using namespace std; // or using std::vector.
...
vector<double>
> I don't know if this is KCC problem.. Sometimes I am forced to use
> <vector.h> instead of <vector> for some reason.
This is not a KCC problem but a problem related to using header files that
'annoyingly' contain statement like 'using namespace std;' or other things
that you should avoid doing if don't want your header to have weird side-effects.
Cheers,
Philippe.
Ps. #include <vector.h> actually does the moral equivalent of #include <vector> ... using std::vector. However it should only be used for C++
compiler backward compatiblities (i.e. don't use it).
-----Original Message-----
From: Jedong Lee [mailto:jdlee@fnal.gov]
Sent: Thursday, July 17, 2003 5:10 PM
To: Philippe Canal
Cc: roottalk@pcroot.cern.ch
Subject: RE: [ROOT] STL in the class
Hi Philippe,
With #include <vector>, I get different error:
----------
root [0] .L vec.C++
Info in <TUnixSystem::ACLiC>: creating shared library /mnt/autofs/misc/b0urpc19.a/jdlee/work/root_test/vector/./vec_C.so
"/mnt/autofs/misc/b0urpc19.a/jdlee/work/root_test/vector/./vec.h", line 10: error #864:
vector is not a template
vector<double> v_;
^
1 error detected in the compilation of "/mnt/autofs/misc/b0urpc19.a/jdlee/work/root_test/vector/./fileibD55q.cxx".
KCC: Compilation failed.
----------
I don't know if this is KCC problem.. Sometimes I am forced to use
<vector.h> instead of <vector> for some reason.
Best,
Jedong
On Thu, 17 Jul 2003, Philippe Canal wrote:
> Hi Jedong,
>
> Use:
> #include <vector>
> instead of the obsolete
> #include <vector.h>
>
> Cheers,
> Philippe.
>
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Jedong Lee
> Sent: Thursday, July 17, 2003 4:25 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] STL in the class
>
>
>
> Hello,
>
> I am working on v3_05_04e, with KCC4.0.
> And I'm having a problem with STL vector.
>
> This is what I get from CINT with the source listed below:
>
> root [0] .L vec.C++
> Info in <TUnixSystem::ACLiC>: creating shared library
> /mnt/autofs/misc/b0urpc19.a/jdlee/work/root_test/vector/./vec_C.so
> "/mnt/autofs/misc/b0urpc19.a/jdlee/work/root_test/vector/./fileonmdDl.h",
> line 44: error #864:
> allocator is not a template
> typedef vector<double,allocator<double> >
> G__vectorlEdoublecOallocatorlEdoublegRsPgR;
> ^
>
> 1 error detected in the compilation of
> "/mnt/autofs/misc/b0urpc19.a/jdlee/work/root_test/vector/./fileonmdDl.cxx".
> KCC: Compilation failed.
>
>
> Is something wrong in my code?
>
> Best,
> Jedong
>
>
> --------------------------------------------------------------------
> - file vec.h
> --------------------------------------------------------------------
> #include <vector.h>
> #include "TObject.h"
>
> class vec : public TObject
> {
> public:
> vec();
> ~vec();
>
> vector<double> v_;
>
> ClassDef(vec,1)
> };
>
> --------------------------------------------------------------------
> - file vec.C
> --------------------------------------------------------------------
> #include "vec.h"
> #include <vector.h>
>
> #ifndef __CINT__
> ClassImp(vec)
> #endif
>
> vec::vec(){
> v_.push_back(10);
> }
>
> vec::~vec(){}
>
> --------------------------------------------------------------------
> - file vec_linkdef.h
> --------------------------------------------------------------------
> #ifdef __CINT__
>
> #pragma link off all globals;
> #pragma link off all classes;
> #pragma link off all functions;
>
> #pragma link C++ class vector<double>;
> #pragma link C++ class vec;
>
> #endif
>
> --------------------------------------------------------------------
>
>
>
>
--
--------------------------------------------------------------------
Jedong Lee Department of Physics and Astronomy
630-840-8428 University of Rochester
jdlee@fnal.gov Rochester, NY 14627
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET