|
Why have you posted this, all it does is confirm that your program causes a stack overflow error? You need to show the code where the error occurs, we cannot be expected to guess what your program is doing.
Veni, vidi, abiit domum
|
|
|
|
|
Go trough your program using your debugger - The debugging stops as soon as the stackoverflow happens.
In case your program stops before entering the debug mode you might want to look into this one:
http://stackoverflow.com/questions/6267837/stack-overflow-error-in-c-before-any-step[^]
If neither one helps you I kindly ask you to post the source code of your main and the classes which are initialized at first - We can't read your mind, nor your HDD.
You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."
|
|
|
|
|
As soon as start program, not operate on any array yet, got error message:
Unhandled exception at 0x77c315de in blast_frag.exe: 0xC00000FD: Stack overflow.
Please help why ?
Thanks
|
|
|
|
|
mrby123 wrote: Please help why ? Because you have a bug in your code.
Veni, vidi, abiit domum
|
|
|
|
|
True.
Veni, vidi, vici.
|
|
|
|
|
Typical sources for stack overflows are declaring large objects on the stack and recursive function calls:
void some_func()
{
int large_array[500000];
CSomeLargeObject Obj;
some_func();
some_other_func();
}
Large objects on the stack should be avoided. Use dynamic memory allocation instead (new or malloc() ).
So check your code for the above conditions. To detect recursive calls, use the debugger and check the functions that are called for recursions.
|
|
|
|
|
So stop using so much stack.
Functions calling themselves endlessly is the usual cause. Dont do it.
|
|
|
|
|
Hi,I recently completed the book Sams Teach yourself C++ and this website was mentioned there for help in further programming process I want some suggestions about getting started with programming in GUI,i am fed up of using console for 3 years learning c and c++
|
|
|
|
|
|
Ok,Thanks
|
|
|
|
|
Farhan_Karim wrote: i am fed up of using console for 3 years learning c and c++
Depending on what "using" means in the context of "3 years" you might want to start learning a different language. Certainly if you have been doing it professionally for 3 years then it is worth consideration. Even an enthusiastic amateur might undertake it.
|
|
|
|
|
The Qt Project[^] offers a great IDE and GUI framework for C++, including examples for the usage of most of the classes.
You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."
|
|
|
|
|
Alright, I've been bugging with this one for quite a while now.
I have a struct which is const and part of a class and therefore I need to initialize it.
What I have done so far:
#ifndef BOUNDARIES_H
#define BOUNDARIES_H
typedef struct{
char upper;
char lower;
} charBoundary;
#endif //BOUNDARIES_H
#ifndef FOO
#define FOO
using namespace std;
#include <iostream> //!< Used for console output
class foo{
private:
const charBoundary versionBoundary = {
1,
-5
};
public:
};
Now I recognized that the initialization
const charBoundary versionBoundary = {
1,
-5
};
is only valid in C++11 - All compilers not supporting C++11 will choke on these lines.
Now I come to the question I want to ask:
Is there any other way to get it compilable to older compilers than making versionBoundary static or non-const or adding a constructor to the charBoundary struct?
I do not like neither of the above mentioned possibilities but if there is no other solution - What would you recommend?
Thanks in Advance
PP
You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."
|
|
|
|
|
Does it have to be const ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Yep, thats why I ask - Without the const it would be easy, also if I'd make it static const.
But for the purpose I need it const only would be the best solution.
You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."
|
|
|
|
|
OK, this is not the most elegant solution, but here we go:
charBoundary getInitialBoundary()
{
charBoundary c ={2,-5};
return c;
}
class foo{
public:
foo() : versionBoundary(getInitialBoundary()) {}
private:
const charBoundary versionBoundary;
};
|
|
|
|
|
Dont you have to do the initialisation in the class constructor?
I am not a C++ expert, I have used it enough, but it seems as if it should go there. If not and you only need one instance of the struct shared among all instances of the clas you can make it static. (Again, not an expert here, but I seem to recall from the dregs f my memoery that this is the case, please correct me anyone if it is not so).
|
|
|
|
|
This is actually a bit of research for an article of mine (If you want to peek into it, have a glance here: Don't mess up your #defines[^]).
Erudite_Eric wrote: Dont you have to do the initialisation in the class constructor?
I initially did this, but as stated in the article the problem is that you'd be able to change the struct's value after the object initialization which could lead to an unexpected behavior of your program. On the other side, making it static const leads to the fact that every instance shares the same instance of the struct, which is possible and would not lead to any unexpected behavior.
I am still searching for a solution which would make it only const , just for design reasons.
Thanks for your post anyways, ŷou brought me onto the track of a false thinking of mine - I refused the static const because I thought I'd have to address the struct as foo::struct which is not the case. Gotta update that article...
You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."
|
|
|
|
|
There are many solutions for your problem if you don't insist on trying to initialize a struct.
1. Write a function. Apparently your purpose is to check a value range, so all you really need is a function:
int inVersionRange(char value);
That's all you need in a header. The implementation file then can contain the actual constants:
const char Min_Version = -5;
const char max_version = 1;
int inVersionRange(char value) {
int result = 0;
if (value < Min_Version)
result = -1;
if (value > Max_Version)
result = 1;
return result;
}
If you need more functions that access these boundaries, put the implementation into the same file.
2. static const
struct VersionRange {
static const char VMIN;
static const char VMAX;
};
const char VersionRange::VMIN = -5;
const char VersionRange::VMAX = 1;
3. define the values within a namespace instead of a struct
(same as above, but you don't need the static keyword)
4. create a singleton class to hold the constants and make them write-only
Similar to 2, but you create an instance of your class (or struct) which is made 'static constant' through programming concepts rather than language keywords.
5. use const references and an array intializer
This comes back to your original idea of using an initializer:
class VersionBoundary {
static const char* const boundaries;
public:
static const char& VMIN;
static const char& VMAX;
}
const char* const VersionBoundary::boundaries = { -5, 1 };
const char& VersionBoundary::VMIN = *(boundaries+0); const char& VersionBoundary::VMAX = *(boundaries+1);
|
|
|
|
|
hello, I found out that listview has tooltip (duaaaaaa)
http://blogs.msdn.com/b/alexdan/archive/2006/05/16/adding-tooltips-to-a-list-view-control.aspx[^]
but how in the world it works? my listview is ONWERDRAW and extended styles lVS_EX_INFOTIP | LVS_EX_LABLETIP, I have been told that I will get an LVN_GETINFOTIP notification, which i do not get it at all, my questions are (Did i miss something?) and (How that tooltip works? I mean does it work when i leave the arrow of item or what?) there are some articles but they did not explain that
working with API and C++ nothing else
thank
|
|
|
|
|
A quick look at the documentation shows where the author got this wrong. When you receive the notification you need to set the tooltip text into the buffer as follows:
sprintf_s(pGetInfoTip->pszText, pGetInfoTip->cchTextMax, "Some helpful tooltip");
Note, this is an over-simplification, and you should check the documentation to ensure you are following the rules.
Veni, vidi, abiit domum
|
|
|
|
|
I am trying to get a pointer to my CDocument derived class associated with a particular tab index (provided by the MDI tab control). The MFC framework calls my OnGetTabToolTip function and provides a CMFCTabToolTipInfo pointer which contains in index of the tab requiring the tooltip text... but it seems there is no way to retrieve the doc/view associated with the tab! Must I keep track of the tab index-doc association, keeping in mind users can move tabs around willy nilly, or is there a better way?
I would have thought this had been discussed countless times, but I cannot find helpful advice.
Many thanks.
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thank you for the reply. Unfortunately, your link does not help solve the problem I described. Perhaps some code will clarify the issue. My ToolTip handler looks like this:
LRESULT CMainFrame::OnGetTabToolTip(WPARAM wp, LPARAM lp)
{
CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*) lp;
ASSERT (pInfo != NULL);
if (pInfo)
{
ASSERT_VALID (pInfo->m_pTabWnd);
if (!pInfo->m_pTabWnd->IsMDITab ())
{
return 0;
}
CWnd *pwnd = pInfo->m_pTabWnd->GetTabWnd(pInfo->m_nTabIndex);
pInfo->m_strText = pDoc->GetTabTipString();
}
return 0;
}
As you can see, a method for getting a pointer to the CDocument derived object CMyDoc from pwnd is needed. From what I have gathered so far, pwnd is a CWnd * to the tab control, and casting it to a (CMyDoc *) does NOT provide a valid pointer (I have tried).
Because the act of clicking on the tab activates the correct doc/view (which is the whole point of having a tabbed MDI), there should be some way of getting a pointer to it.. but I cannot see how this is done.
|
|
|
|
|
Also, I should emphasize that the CMyDoc pointer is not necessarily the active document. It can be any document associated with a tab.
|
|
|
|
|