This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
classes and templates correct order.
- To: gcc-help at gcc dot gnu dot org
- Subject: classes and templates correct order.
- From: Roberto Diaz <rdiazmartin at vivaldi dot dhis dot org>
- Date: Fri, 8 Jun 2001 17:08:32 +0200 (MEST)
I will explain better: It seems it is not important the order of
declaratinon in the header file for classes so I can have:
class A {
B c;
.... etc...
};
class B {
...etc..
};
and it works.. but it is not the same for templates:
This does not work..
class A {
B<int> a;
... etc ..
};
template <class T > B {
...etc..
};
It seems the header file must to declare templates firsly to use
them.. but it is not the case for classes..
I also would like to know how could I put my template's functions in
another file but the header (in order to make a library) without recieving
compalinings about unresolved symbols) (some trick to get storage for
templates?)
Thank you!
> Hi!
>
> I have been searching the lists available at gcc.gnu.org I wonder if this
> one is the correct one to send doubts about g++.
>
> I have this problem:
>
> this compile without problems:
>
> template< class T >
> class threadData {
> public:
> threadData ();
> ~threadData ();
> T* operator->();
> T &getObject () {return object;}
> pthread_mutex_t getMutex () {return localMutex;}
> private:
> pthread_mutex_t localMutex; // mutex to protect this object
> pthread_cond_t localCond; // local conditional variable
> T object; // our real object
> };
>
> // see function definitions below.
>
> // our exception (thread::run() thread::threaded() ) ----->
> template < class T >
> class runError {
> friend class thread;
> friend class threadData < T >;
> public:
> ..... etc ....
>
> So I have two friends declared.. the class thread is defined later in the
> header file *after* runError.. this is not causing me troubles.. the
> problem is that if I try to define the template threadData *after*
> runError then g++ complaints and says something like "threadData not a
> template"..
>
> sorry if this is not the correct list to ask this questions.. I was
> looking for g++-help without success..
>
> Thank you!
>
> Regards
>
> Roberto
>
> ------------------------------------------------------------------------
> Roberto Diaz <rdiazmartin@vivaldi.dhis.org>
> http://vivaldi.dhis.org
> Powered by GNU running on a Linux kernel.
> Powered by Debian (The real wonder)
>
> Concerto Grosso Op. 3/8 A minor
> Antonio Vivaldi (so... do you need beautiful words?)
> ------------------------------------------------------------------------
>
>
Regards
Roberto
------------------------------------------------------------------------
Roberto Diaz <rdiazmartin@vivaldi.dhis.org>
http://vivaldi.dhis.org
Powered by GNU running on a Linux kernel.
Powered by Debian (The real wonder)
Concerto Grosso Op. 3/8 A minor
Antonio Vivaldi (so... do you need beautiful words?)
------------------------------------------------------------------------