M
macAWM
Hi list,
First let me explain that my background is in Java and I am quite
spoiled to its niceties (read "less ambiguous nature"). Anyway to my
problems.
1. I want to write my own library for what I consider to be some holes
in the standard language. How do I go about writing and compiling this
without this stupid error about not having a 'main' function. I don't
want a stupid 'main' function. (I'm compiling using gcc 4.0.) I would
also like to have all my functions use the std:: scope.
2. For the time being I want this library to be a two file entity, a
header file and an implementation file. Below is what I'm testing but I
can't discern the errors the compiler is throwing at me. I'm obviously
not educated on the finer details of c++ but I've got a pile of books
and this is what I gathered on my own.
<code>
Header:
template <typename T>
string toString(const T &);
cpp file:
#include <sstream>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;
template <typename T>
string toString(const T &i) {
ostringstream oss;
oss << fixed << i;
return oss.str();
}
</code>
3. Now obviously I don't need an executable file, just object code. How
do I simply compile for object code and package it?
TIA,
Anthony
First let me explain that my background is in Java and I am quite
spoiled to its niceties (read "less ambiguous nature"). Anyway to my
problems.
1. I want to write my own library for what I consider to be some holes
in the standard language. How do I go about writing and compiling this
without this stupid error about not having a 'main' function. I don't
want a stupid 'main' function. (I'm compiling using gcc 4.0.) I would
also like to have all my functions use the std:: scope.
2. For the time being I want this library to be a two file entity, a
header file and an implementation file. Below is what I'm testing but I
can't discern the errors the compiler is throwing at me. I'm obviously
not educated on the finer details of c++ but I've got a pile of books
and this is what I gathered on my own.
<code>
Header:
template <typename T>
string toString(const T &);
cpp file:
#include <sstream>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;
template <typename T>
string toString(const T &i) {
ostringstream oss;
oss << fixed << i;
return oss.str();
}
</code>
3. Now obviously I don't need an executable file, just object code. How
do I simply compile for object code and package it?
TIA,
Anthony