🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: hepnet.lang.c++
2 messages
2 total messages Started by bob Thu, 01 Dec 1994 15:10
How to construct class member - template object using non-default constructor ?
#13
Author: bob
Date: Thu, 01 Dec 1994 15:10
35 lines
1822 bytes

Hello, All !!!

I have template class with only one constructor, which has parameters 
(non-default constructor). I want some object of this class to be a member of 
another class, but not a pointer. Here is an example:

template <class T>
class A
{
public:

  A (int param);
  ...
  int func (void);

};


class B
{

  A<int> a(5);  // this doesn't work. What can I do to make it work, without 
                // changing it to pointer
  ...

Can anyone tell me, why BCW 4.0 Linker doesn't find all non-inline functions of 
class A. I put them all in the same header file as required by "Smart 
Templates" option of BCW 4.0, but I get linker error: "Undfined symbol 
A<int>::func (void) in module ...".

Please e-mail me.
Thanks, beforehand.
Bob.
Re: How to construct class member - template object using non-default constructor ?
#14
Author: Zijian Huang
Date: Tue, 27 Dec 1994 01:04
18 lines
1583 bytes
In article <NEWTNews.10770.786299039.bob@koba.elementrix.co.il>, bob@elementrix.co.il says:
>

>Please e-mail me.
>Thanks, beforehand.
>Bob.
>
Answer:
  I am not sure what is the meaning--'put them all in the same header file...'
Usually, in C++, you should put or include the implementation code for
the template class into the 'same' header file. That is the way you should
do in BC, though some C++ compiler can handle something like 'temp.h' and
'temp.c' and then produce 'temp.o'.

Zijian Huang
Computing Science Dept
University of Newcastle upon Tyne
Zijian.Huang@ncl.ac.uk
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads