when I compile this code I get the following errors:
email2.cpp:27: undefined reference to `email_client::payload_text'
email2.cpp:28: undefined reference to `email_client::payload_text'
email2.cpp:29: undefined reference to `email_client::payload_text'
email2.cpp:30: undefined reference to `email_client::payload_text'
email2.cpp:31: undefined reference to `email_client::payload_text'
/tmp/ccE0wEII.o:email2.cpp:32: more undefined references to `email_client::payload_text' follow collect2: error: ld returned 1 exit status
my declaration signature matches my definition one, so I'm not sure what to make of these errors. please help.
cpp
#include <curl/curl.h>
#include <cstdio>
#include <string>
#include "email.h"
char* cat_char(std::string first, const char* second) {
char* tmp = new char[first.size()];
strcpy(tmp, first.c_str());
strcat(tmp, second);
strcat(tmp, "\r\n");
return tmp;
}
char* cat_char(std::string first) {
char* tmp = new char[first.size()];
strcpy(tmp, first.c_str());
strcat(tmp, "\r\n");
return tmp;
}
email_client::email_client(message msg, std::string TO, std::string FROM):
m_to(TO.c_str()),
m_from(FROM.c_str())
{
payload_text[0] = cat_char("To: ", TO.c_str());
payload_text[1] = cat_char("From: ", m_from);
payload_text[2] = cat_char("Subject: ", msg.subject.c_str());
payload_text[3] = cat_char("", "\r\n");
payload_text[4] = cat_char(msg.body, "\r\n");
payload_text[5] = NULL;
};
header
#include <string>
#include <cstring>
#include <cstdio>
struct message{
std::string subject;
std::string body;
};
char* cat_char(std::string first, const char* second);
char* cat_char(std::string first);
class email_client{
const char* m_to;
const char* m_from;
static char* payload_text[];
public:
email_client(message msg, std::string TO, std::string FROM="test@stest.com");
};