1. Problem with templates (apparently a linker problem)
{ Would someone be willing to draft an FAQ around this topic? -vdv }
I'm running into trouble in defining a class template for create
dynamic bidimensional arrays.
I want to define an array of whatever data type (that's why I'm
trying to use a class template), but I have a message of unresolved
names (with the g++ compiler) when I try to define an object which
is a bidimensional array of ints.
Maybe I'm just missing some switch in the command line? (like, say,
when you use any math function and you forget to put the -lm switch
at the end?). I checked the man pages and the FAQ, but found no
clues to help me solve the problem.
Any help will be highly appreciated! (BTW, if possible, reply by
e-mail - or at least send me a Carbon-Copy, if you decide to post
a reply). I'm including the code at the bottom of the message.
Thanks a lot!
Carlos
--
In file ARRAYS.H:
template<class DT>
class dynamic_array
{
public:
dynamic_array ();
dynamic_array (int, int);
~dynamic_array ();
DT & operator() (int, int);
// void redim (int, int, int = 0); Not implemented yet
// void ubound (int); Not implemented yet
private:
DT ** data;
int size_subscript_1;
int size_subscript_2;
In file ARRAYS.C++:
#include "arrays.h"
template<class DT>
dynamic_array<DT>::dynamic_array ()
{
cerr << "Error: Must specify dynamic array size!" << endl << endl;
exit (1);
template<class DT>
dynamic_array<DT>::dynamic_array (int size1, int size2)
{
data = new DT * [size2];
..... (the rest of the code ommited)
In file TEST.C++:
#include <iostream.h>
#include "arrays.h"
main ()
{
dynamic_array<int> array; /* Should invoke the default constructor
and print an error message */
// .....
cout << "I worked!" << endl;
(this simple program should print an error message and quit; though,
it does not compile... :-( ...)
[ about comp.lang.c++.moderated. First time posters: do this! ]
2. NFSS2: nfeuler.sty + cm-fonts ...
3. C++ kernel linker problems - help please!
4. Warp Server Beta?
5. Watcom linker problem
6. Nick's web/ftp site down?
7. Perplexing problem with Unresolved external symbol linker errors
8. Clarification on recent NYT article
9. /OPT:REF linker problem with MSVC++
10. linker problems with 2 part source?
11. Linker Problems using OWL
12. Help! BC++/OWL Linker problem.
13. Q.Linker problems