>I was wondering if the following is considered poor practice, as the object is not
created in main.
Yes, but not because the object isn't created in main. It's because the object is defined in a header file. If you include the header more than once in your project (as would be expected), you'll get multiple definition errors from the linker. The proper way to do something like this is to define the object in an implementation file and simply declare it in the header file:
Code:
#ifndef HEADER_H
#define HEADER_H
class Foo
{
public:
Foo() {};
~Foo();
private:
int something;
};
extern Foo fo;
#endif
Code:
#include "header.h"
Foo fo; // Define here, link this file, and be happy