[Daved: xtree is much bigger than me. I don't understand it one bit...]
OK... I've made a 'test' example (it's good practice, something I don't have. Yay). It compiles, but doesn't work. I'm sure this isn't a particularly obscure problem - if it is, then I'm approaching it in the wrong way maybe?
minicgi.h
Code:
#include <iostream>
#include <map>
#include <string>
class CLASS
{
public:
static std::map<std::string, std::string> params;
void save_param( char *_nvpair );
};
minicgi.cpp
Code:
#include "minicgi.h"
std::map<std::string, std::string> CLASS::params;
void CLASS::save_param( char *_nvpair )
{
char *n = _nvpair;
char *v = strchr( _nvpair, '=' ); // this points just before 'value' begins
if( v[0] != 0x00 ){
v[0] = 0x00; // seperates n from v
++v; // now v points to 'value'
params[n] = v; // assign to the map<>
}
}
test_main.cpp
Code:
#include "minicgi.h"
int main(void)
{
CLASS c;
c.save_param("bill=bob");
std::cout<< c.params["bill"] << std::endl;
return 0;
}
Incidentally I found that the line: v[0] = 0x00 causes an error here. That is confusing, since in the full class that I'm using, that exact same line works. Also, wierdly, the map seems to work on this example (at least if you set the n/v manually, which isn't any help), but not on the other.
Either way, that code worked perfectly - consistently - before I split the class into the two files. My utter noobishness in such matters is baffling.