I'm new to C++ and want to achieve something extremely simple, but it will not let me. I've read a bunch of ways to "assign" or "link" or "copy" arrays, but NONE of these seem to work at all.
Consider the following:
in file: header.h:
using namespace std;
Class Proc
{
public: static char args;
};
in file: main.cpp:
using namespace std;
#include <cstdlib>
#include <memory>
#include "header.h"
int main(int argc, char* argv[])
{
Proc::args = argv; // yea i know this won't work :(
// Proc::args[argc] = argv; // not working either
// memcpy(argv, Proc::args, sizeof(argv)); // nope
// copy(begin(argv), end(argv), begin(Proc.args)); // nope
}
In fact I don't really want to "copy" it at all, linking it is just fine, but the g++ compiler keeps throwing up in my face about undefined reference to 'Proc::args' and who knows what else.
I'm about to put a drill to my ear, can anyone please make an example?
It is different from undefined reference to'Proc::args'because I also get:error: invalid use of qualified-name 'Proc::args'and also that it complains aboutchar**&char*not being the same...
- and when I add an asterisk to Proc'schar* args` then it throws some more.
argsisn't an array, for starters. It's a single character.argvto theProc.args, as it complains about the datatype being incompatible, where clearly they are the same, or so I think?