Hello,

I have got a problem of An unhandled exception of type 'System.StackOverflowException'.

I have read that it is possible that the reason is that I have too many method calls.

I am working with a GUI and I didn't want that the code in Form() was too big so I thougth I could make a function, similar to C, in another .cpp and this way having there the code and making a call from Form().

Form()
void labelling ()
{
    bwlabel(image,8);
}

bwlabel.h

void order(void);
void bubble(void);
void bwlabel (System::Drawing::Bitmap^ image, int number);//inside bwlabel I use order() and bubble().

Could be that the reason of the error? and if it is, what can I do to solve it?

Thank you in advanced!!

Maybe you have a following kind of scenario ...

void fun1();

void fun2()
{
    fun1();
}

void fun1()
{
    fun2();
}

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

it is not exactly that. I have got:

void main()
{
    bwlabel(image,8);
}

bwlabel.h

void order(void);
void bubble(void);
void bwlabel (System::Drawing::Bitmap^ image, int number);

bwlabel.cpp

void order(void)
{
   //instructions
}
void bubble(void)
{
     //instructions
}

void bwlabel (System::Drawing::Bitmap^ image, int number)
{
    order()
    bubble()

}

I think that it is not the same scenario but maybe I am wrong!

it is not exactly that. I have got:

void main()
{
    bwlabel(image,8);
}

bwlabel.h

void order(void);
void bubble(void);
void bwlabel (System::Drawing::Bitmap^ image, int number);

bwlabel.cpp

void order(void)
{
   //instructions
}
void bubble(void)
{
     //instructions
}

void bwlabel (System::Drawing::Bitmap^ image, int number)
{
    order()
    bubble()

}

I think that it is not the same scenario but maybe I am wrong!

That should be OK, depends of course on what order() and bubble() actually are doing.

PS. void main() should really be int main() see e.g.
http://www.research.att.com/%7Ebs/bs_faq2.html#void-main

ok, thank you so much!!

I'll see if I find a solution!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.