Why isn't my object being created?
And how can I execute AllReferrals.push_back(this);
from my constructor?
When I do it like so, I am told
error C2065: 'AllReferrals' : undeclared identifier
as well as
error C2228: left of '.push_back' must have class/struct/union
If I put the list initialization before the class I get
error C2065: 'AllReferrals' : undeclared identifier
Here is my code:
class Referral
{
public:
string url;
map<string, int> keywords;
static bool submit(string url, string keyword, int occurrences)
{
//if(lots of things i'll later add){
Referral(url, keyword, occurrences);
return true;
//}
//else
// return false;
}
private:
list<string> urls;
Referral(string url, string keyword, int occurrences)
{
url = url;
keywords[keyword] = occurrences;
AllReferrals.push_back(this);
}
};
static list<Referral> AllReferrals;
int main()
{
Referral::submit("url", "keyword", 1);
}