Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ Class declaration after main?

#include "stdafx.h"
using namespace System;

class Calculater; // how to tell the compiler that the class is down there? 

int main(array<System::String ^> ^args)
{
    ::Calculater *calculater = new Calculater();

    return 0;
}

class Calculater
{
public:
    Calculater()
    {
    }
    ~Calculater()
    {
    }

};

Im declaring the class after main, how do i tell the compiler were my class is? i tried
class Calculater; before main but its not working.

like image 631
Anthony Raimondo Avatar asked Dec 12 '22 16:12

Anthony Raimondo


1 Answers

You can't do it how you've written it. The compiler has to be able to see the definition of the class before it can use it. You need to put your class before your main function, or preferably in a separate header file which you include.

like image 114
Jonathan Potter Avatar answered Dec 30 '22 05:12

Jonathan Potter