Welcome to Dream.In.Code
Become a C++ Expert!

Join 150,035 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,580 people online right now. Registration is fast and FREE... Join Now!




Compiler Error

 
Reply to this topicStart new topic

Compiler Error, Function Definition Not Allowed

Delta_Echo
1 Feb, 2008 - 10:03 PM
Post #1

D.I.C Regular
***

Joined: 24 Oct, 2007
Posts: 480


My Contributions
Sorry, i would have put the post here but, when I include any code tages i get a 403 forbidden sad.gif.
So i included it as an attachment.


Btw, anyone know how to fix 403 forbidden errors? ty


Attached File(s)
Attached File  post.txt ( 4.3k ) Number of downloads: 21
User is offlineProfile CardPM
+Quote Post

Bench
RE: Compiler Error
2 Feb, 2008 - 01:59 AM
Post #2

D.I.C Addict
Group Icon

Joined: 20 Aug, 2007
Posts: 686



Thanked: 24 times
Dream Kudos: 150
Expert In: C/C++

My Contributions
The error you're getting is because you're missing an ending curly bracket off your m_men function.
Since the m_men function doesn't end properly, when you #include the header file in your main program, the compiler sees you trying to define int main() as part of the m_men function.


Your real problem is that your code's formatting is misleading (Remember that indentation is for your benefit only, not the compiler's). If you use a consistent indenting style throughout your code, then these errors become far easier to see.

I found the error in a few seconds by using my IDE's auto-indent feature. If your IDE doesn't let you auto-indent, then you may wish to find a text editor or other IDE which does - failing that, be disciplined and take time to line up all your brackets when you're writing code. This way you can clearly see the beginning and end of different blocks.
eg,
CODE
void func()
{
    for( int i=0; i<10; ++i )
    {
        if( i % 2 == 0 )
        {
            std::cout << "Even number: " << i;
        }
    }
}


This post has been edited by Bench: 2 Feb, 2008 - 02:05 AM
User is offlineProfile CardPM
+Quote Post

Delta_Echo
RE: Compiler Error
2 Feb, 2008 - 01:01 PM
Post #3

D.I.C Regular
***

Joined: 24 Oct, 2007
Posts: 480


My Contributions
Thanks for the tips smile.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 09:43PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month