Yep, the following compiles and runs perfectly in VS2005:
Code:
void LocalClass()
{
class wibble{
char str[32];
public:
wibble(char *t){strcpy_s(str,30,t);}
void prt(){printf("%s\n",str);}
};
wibble a("Hello LocalClass");
a.prt();
}
and if I place void prt(){printf("%s\n",str);} into a separate file foo.txt, the following also compiles and runs without error;
Code:
void LocalClass()
{
class wibble{
char str[32];
public:
wibble(char *t){strcpy_s(str,30,t);}
#include "foo.txt"
};
wibble a("Hello LocalClass");
a.prt();
}
You can place #includes anywhere; it's just a lexical thing done by the preprocessor so it's not limited to header files only; you can #include whatever you want wherever you want. Probably worth commenting the code though if you're going to do something non-headery with it such as this.