🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Tim Budd Thu, 30 Jul 1992 16:36
Simple Question
#131
Author: Tim Budd
Date: Thu, 30 Jul 1992 16:36
29 lines
1367 bytes
Let me appologize in advance for what is probably a trivial question,
and one that is probably asked incessantly.  Our support people seemed to 
have installed g++ 2.2.2, but I can't locate any of the documentation or
test cases.  I can get templates to work within a single file, but not
split between two files.  Can somebody explain what I must do to get
the following minimalist program to work.  At present it produces linker
errors (at least on my machine).

------file box.h ------------------
template <class T> class box {
public:
	box(T val);
	T getValue();
private:
	T value;
};
-----file box.cc -----------------
# include "box.h"
template <class T> box<T>::box(T val) : value(val) { }
template <class T> T box<T>::getValue() { return value; }
-----file test.cc --------------
# include "box.h"
# include <iostream.h>
main() {
	box<int> aBox(7);
	cout << "abox contains " << aBox.getValue() << '\n';
}

many thanks.
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