Question: I'm watching some video tutorials on C++ and i know you must define a function / class before it is used or called. But I like having my main() function at the top, and everything else below the main function. I know if i define a function below the main function I must declare it before it is used, but what about a class? What do I need to put above my main function to use my class below the main function.

```
#include <iostream>
using namespace std;

int main()
{
    ClassOne one;
    one.coolSaying();
    return 0;
}

class ClassOne
{
    public:
        void coolSaying()
        {
            cout << "Cool stuff yo!" << endl;
        }
};

```

I tried defining my class by placing this right before main():

```
class ClassOne;

```

but it doesn't work.

Answer: 
A class MUST be "complete" when you create an instance of it. So there is no way you can use the class before you have defined the whole content of the class. 

It is possible to do something like this:

```
class ClassOne;
ClassOne* make_class_one();
void use_class(ClassOne *x);

int main()
{
    ClassOne* one = make_class_one();

    use_class(one);
    return 0;
}

class ClassOne
{
    public:
        void coolSaying()
        {
            cout << "Cool stuff yo!" << endl;
        }
};

ClassOne* make_class_one()
{
     return new ClassOne;   // Bad idea, use uniqe_ptr, but I'm lazy.
}

void use_class(ClassOne *x)
{
    x->coolSaying();
}

```

But in general, we don't want to do that.
One scenario where the class definition after the main() function makes sense:

```
#include <iostream>
using namespace std;

void f();

int main()
{
    f();
    return 0;
}

class ClassOne
{
    public:
        void coolSaying()
        {
            cout << "Cool stuff yo!" << endl;
        }
};

void f()
{
    ClassOne one;
    one.coolSaying();
}

```