btw: the -_- is a face looking gloom, not a var name
Code:
#include <iostream.h>
class Person
{
private:
static int myCount;
char* name;
public:
Person(char* name)
{
this->name=name;
myCount++;
}
Person()
{
name="Unknown";
myCount++;
}
virtual ~Person()
{
myCount--;
name="";
}
static int count()
{
return myCount;
}
friend ostream& operator<<(ostream& out, Person& in);
};
ostream& operator << (ostream& out, Person& in)
{
out<<in.name;
return out;
}
int main()
{
Person john("John");
Person* ptr = new Person("Johnny boy");
cout<<john<<endl;
cout<<*ptr<<endl;
cout<<Person::count()<<endl;
delete ptr;
cout<<Person::count()<<endl;
return 0;
}
Just playing around with something and I get the error:
Code:
haha.obj : error LNK2001: unresolved external symbol "private: static int Person::myCount" (?myCount@Person@@0HA)
I tried playing with some different ways of putting it etc but couldn't really come up with something that worked. Anyone have an idea of what's wrong besides the fact that im using windows -_-.
-LC