#define cString std::string
As has been pointed out, this
#define
is questionable. And it's bad style for C++. If you really need an alias, use
typedef
instead.
class cPlainKeyDummy : public cPlainKey {
At this point we must ask: where's the definition of cPlainKey?
protected:
virtual cString Print(void);
While this may not necessarily be the case, this implies there is a virtual function of that same name defined in the base class.
}
If that's the closing bracket for your class definition, you're missing a '
;
' here!
cString cPlainKey::ToString(bool hide)
Why did you post that code? I don't see it's being used in the rest of the code you posted. Has something gone missing you meant to post as well?
char *tmp;
sprintf(tmp, (hide ? "%c %.*X %s %.4s..." : "%c %.*X %s %s"),type,IdSize(),id,&PrintKeyNr(),&Print());
return tmp;
Ugh, that is wrong on so many levels ...
* First, you define a char pointer and don't initialize it.
* Then you create a string using that pointer without allocating memory first - so you're writing into an undefined memory location!
* Next, the format string you use - both of them - refer to 4 values, but then you provide 5 parameters!?
* Looking at these parameters, the last two are addresses? You didn't provide the prototype for
PrintKeyNr()
, but the return type of Print() is of type
std::string
, and address-of(std::string) is not a valid argument type you can sensibly pass to sprintf, except for printing a memory address! Of course, this consideration is moot since that is the fifth parameter which will be ignored anyway...
* Besides, what are the symbols
type
,
id
, and the function
IdSize()
?
* P.S.: most of the format specifiers don't make much sense to me either, e. g. 's' denotes a string and '.NN' refers to decimals of a float - so what does '%.4s' mean?
cString cPlainKeyDummy::Print(void)
{
return string(str);
}
What exactly is the function
string
? and what is the symbol
str
referring to?
We may not need all the information I asked about, but you at least have to give us some, and then copy it correctly, so we can properly parse the relevant information. Most importantly, the linker complained about a missing function implementation:
std::string cPlainKey::Print(void)
, and that means you called it somewhere: please show us the code where you create the
cPlainKey
object and call the function.