|
Yes I define my own Max function, but why the output is 4,3,1 and not only 4?
|
|
|
|
|
i think the return should be
return currentDepth+(maxDepth,rightdepth);
|
|
|
|
|
maxDepth is? and why is it in brackets? Is it a function or something? i don' t know
|
|
|
|
|
OK I think I did it it has to be
return currentDepth - leftDepth + rightDepth;
|
|
|
|
|
Now If you can explain me how the whole function works...
|
|
|
|
|
it works by only printing those nodes who have only one depth below them, no more
|
|
|
|
|
return currentDepth+max(leftDepth,rightdepth)
|
|
|
|
|
And how to call the function? I mean what has to be the second argument innerDepth. I call it with the tree and the Height as second argument and it gives me 4, 3, 1 as output. I need only 4.
|
|
|
|
|
call it with
OnlyLeafNodes(rootNode,0);
|
|
|
|
|
Hi Everyone,
When i build my newly ported(VS6.0 to 2008) code from VS2008 UI, It builds fine.
When i build it using
MSBuild XXX.sln /t:Clean /p:configuration=Release
MSBuild XXX.sln /l:FileLogger,Microsoft.Build.Engine;logfile=MyLog.log;Build /p:configuration=Release
I get 100's of
nafxcw.lib(winctrl1.obj) : error LNK2005: "public: virtual int __thiscall CStatic::Create(char const *,unsigned long,struct tagRECT const &,class CWnd *,unsigned int)" (?Create@CStatic@@UAEHPBDKABUtagRECT@@PAVCWnd@@I@Z) already defined in mfc90.lib(mfc90.dll)
nafxcw.lib(winctrl1.obj) : error LNK2005: "public: virtual __thiscall CStatic::~CStatic(void)" (??1CStatic@@UAE@XZ) already defined in mfc90.lib(mfc90.dll)
I used the NODEFAULTLIB option in UI. With this option, UI is also failing to build.
If somebody ran into same issue, please advise.
|
|
|
|
|
Hi,
i sometimes get a overflow at runtime when using boost::regex_match...
here's what i'm doing (This code works!):
CString path = "abcd";
boost::regex r("bc");
boost::tmatch what;
if(boost::regex_match(path, what, r))
{
}
else
{
}
When i'm changing the code to
boost::regex r("*bc");
i'll get the error?
I have also tried 'BOOST_REGEX_NON_RECURSIVE' or 'BOOST_REGEX_RECURSIVE'.
Thanks
|
|
|
|
|
boost::tmatch what;
if(boost::regex_match(path, what, r))
Variable what has not been initialized, is this correct?
The best things in life are not things.
|
|
|
|
|
Yes, that's correct.
My code is like the first sample of this link.
|
|
|
|
|
Sorry, but I cannot see anything wrong there. I guess you need to use the debugger and try to trap the error.
The best things in life are not things.
|
|
|
|
|
On a side issue, try to make r static const . The static is particularly important: the regular expression should only be "compiled" once, not every time.
Steve
|
|
|
|
|
Thanks, but that did not matter...
This is the exact error message:
Unhandled exception at 0x7c81eb33 in Hierarchy Explorer.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::regex_error> > at memory location 0x0012ddc4..
|
|
|
|
|
I knew it wouldn't help, it was a side issue. Can you post a small self-contained program that exhibits the problem?
Steve
|
|
|
|
|
Your regular expression isn't valid. What's more, the program is trying to tell you what's wrong. I used the following code:
void Go()
{
try
{
CString path = _T("abcd");
static const boost::tregex r(_T("*bc"));
boost::tmatch what;
if(boost::regex_match(path, what, r))
{
}
else
{
}
}
catch (const boost::regex_error &e)
{
cout << e.what() << endl;
throw;
}
}
The following error is the result:
The repeat operator "*" cannot start a regular expression. The error occured while parsing the regular expression: '>>>HERE>>>*bc'.
The regular expression you're probably after is: .*bc
Steve
|
|
|
|
|
Thats it!
I will have to give the boost syntax more attention... thank you!!
|
|
|
|
|
The syntax isn't boost specific, it's standard regular expression syntax.
Steve
|
|
|
|
|
You're right.
I've played a while with the syntax... you can use it for almost enything!
Actually I have been looking for filter like it is used in SQL queries. I Only wanted to use the *, ?, bracket, AND, OR-statements.
Are regular expressions perhaps a bit too complex for that purpose?
I don't want people to study regular expressions before using my program.
Do you perhaps have a recommendation to me?
|
|
|
|
|
A basic understanding of regular expressions is kind of an must have these days.
Steve
|
|
|
|
|
Hi ALL,
outside a while loop, I declare a 3-D vector array
vector<struct Person> Psodu;
Psodu.reserve(10);
vector<vector<vector<struct Person> > > structPersonVar(2, vector<vector<struct Person> >(2,Psodu));
in the while loop, i have to change the size of the array in every iteration.
First, I use the following code to release the memory
<br />
for(int j=0; j < 2; j++)<br />
{<br />
for(int k =0; k < 2; k++)<br />
{<br />
vector<struct Person>().swap(structPersonVar[j][k]);<br />
}<br />
vector<vector<struct Person> >().swap(structPersonVar[j]);<br />
}<br />
<br />
vector<vector<vector<struct Person> > >().swap(structPersonVar);<br />
<br />
Then, I resize the array
structPersonVar.resize(20);
for(j=0; j < 12; j++)
{
structPersonVar[j].resize(2);
for(int k =0; k < 2; k++)
{
structPersonVar[j][k].reserve(10);
}
}
I am not very sure whether i am correct by doing in this way,though it works fine with testing program.
|
|
|
|
|
Hello ALL,
Initially, I declare Var[1][1] as
vector<vector<string> > Var(1, vectort<string> (1));
later, I want to expand Var to be Var[5][6]
How to do this.
Thanks
modified on Monday, April 18, 2011 11:10 AM
|
|
|
|
|
You want Var to grow to 5 and each element in Var to grow to 6. If i got it correctly, this can be a solution.
vector<vector<string> > Var(1, vector<string>(1));
Var.resize(5);
for (int i=0; i<5; ++i)
{
Var[i].resize(6);
}
|
|
|
|