|
First, it would have been helpful if you had marked the error locations for us
I counted to line 37 and found this:
CountedPtr<T>& operator= (const CounterPtr<T>& p) throw ()
{
if (this != &p)
{
release();
ptr = p.ptr;
count = p.count;
++*count;
}
return *this;
}
Have a look at the spelling where I've underlined.
Steve
|
|
|
|
|
Thank you very much! Next Time I will try to indicate where the error is.
RobNO.
|
|
|
|
|
You got your message posted while I was still counting lines!
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I actually pasted it into an editor which shows line numbers...
Steve
|
|
|
|
|
time to use Notepad++
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
RobNO wrote:
CountedPtr<T>& operator= (const CounterPtr<T>& p) throw ()
{
Spelling the class name consistently would probably help...
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Watch-out for typos in your program in the operator =, you've used CounterPointer instead of CountedPointer
-Sarath.
Rate the answers and close your posts if it's answered
|
|
|
|
|
Hi All,
I am trying to get a splitter window for MDI when a Menu Item in Menu is clicked. The splitter window is been created but when i am trying to drag that Splitter it is not able to split also it is not performing the events of the pane. (i.e) if in Pane2 of the splitter i am having a Button Control it is not been handled.
Help me out!
Thanks,
Uday.
Here is the Code.
-----------------
void CMainFrame::OnMytreeTree()
{
CCreateContext ctx;
ctx.m_pNewViewClass = RUNTIME_CLASS(CudayView);
// GetActiveDocument() call before you destroy m_splitter.
ctx.m_pCurrentDoc = GetActiveDocument();
//ASSERT(ctx.m_pCurrentDoc!=NULL);
// m_pSplitter !=NULL when there is a visible splitter.
if (m_pSplitter)
{
// Destroy splitter window.
delete m_pSplitter;
m_pSplitter = NULL;
// Create and initialize CMyView.
SetActiveView((CView*)CreateView(&ctx));
GetActiveView()->OnInitialUpdate();
}
else
{
if(m_pSplitter == NULL)
{
//MDIGetActive()->DestroyWindow();
// Create new splitter window.
m_pSplitter = new CSplitterWnd;
if (!m_pSplitter->CreateStatic(this, 1, 2))
{
TRACE0("Can't create splitter window.\n");
return;
}
else
{
if ((!m_pSplitter->CreateView(0, 0,
RUNTIME_CLASS(CMyTreeView),
CSize(200, 0), &ctx))
||(!m_pSplitter->CreateView(0, 1,
RUNTIME_CLASS(CFirstView),
CSize(500, 0), &ctx)))
{
TRACE0("Can't create one of the splitter panes.\n");
return;
}
// Initialize the two panes (each containing a view
// associated with the current document).
((CView*)m_pSplitter->GetPane(0, 0))->OnInitialUpdate();
((CView*)m_pSplitter->GetPane(0, 1))->OnInitialUpdate();
SetActiveView((CView*)m_pSplitter->GetPane(0, 0));
}
}
}
// Redisplay frame.
RecalcLayout();
}
|
|
|
|
|
Hello,
Can anyone tell me why the "index" variable isn't changing in my while loop, despite the fact that the vector "vec" has several "0." values stored in it? My goal is to find the index of each zero value in the vector "vec". The very first value calculated for the "index" variable is correct, but for the following loops in the while statement, it never updates from this value.
Thanks!
vector <long double>::iterator varying_start;
varying_start=vec.begin();
vector <long double>::iterator start;
start=vec.begin();
while(true)
{
varying_start= find(varying_start,vec.end() , 0.);
int index=varying_start-start;
}
|
|
|
|
|
Don't you want to use varying_start= vec.find(varying_start,vec.end() , 0.); instead of varying_start= find(varying_start,vec.end() , 0.); ? I'm not saying this is the answer, but it could be.
|
|
|
|
|
Hello,
If I do that then I get the following error:
eror C2039: 'find' : is not a member of 'std::vector<_Ty>'
|
|
|
|
|
What are the elements of your vector?
|
|
|
|
|
0.000000
0.000000
0.013180
0.424146
1.300951
2.690247
4.658776
6.345779
7.057368
7.186754
6.796806
6.209223
6.240955
6.789929
7.257117
7.541815
7.229695
5.995904
4.311499
2.421349
0.651686
-0.396626
-0.931562
-1.667433
-3.014668
-5.174474
-7.164814
-7.445005
0.000000
|
|
|
|
|
b-rad311 wrote: Can anyone tell me why the "index" variable isn't changing in my while loop, despite the fact that the vector "vec" has several "0." values stored in it?
Because varying_start always "points" to the same starting location. Increment it after the index assignment. You'll also want to provide a way out of the while() loop.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
You need to increment varying_start after the assignment. You also need to check the return from find() to see whether you have hit the end of the vector.
[edit]I see David posted the answer while I was running my tests[/edit]
It's time for a new signature.
|
|
|
|
|
The problem is that when std::find succeeds it's referring to an element holding a zero. At the moment when you call std::find again the first element in the range with a zero in it is the one it's just found.
for( std::vector<long double>::iterator start = v.begin(); start != v.end(); )
{
start = std::find( start, v.end(), 0 );
if( start != v.end() )
{
indices.push_back( start - v.begin() );
++start;
}
}
You can probably collapse a few of the lines down a bit but it's probably not worth it unless you like code to tease the reader.
The important differences between this and your original version is the ++start line. If you find a zero it bumps the iterator past it so the next call to find doesn't return hit the same thing again.
Cheers,
Ash
PS: This is actually just what David and Richard said in their posts, I'll read the entire thread next time before answering 
|
|
|
|
|
Thanks Ash.
This is a very good explanation!
|
|
|
|
|
Hi,
Does anyone know if have to create a copy of IRichEditole
before SendMessage EM_GETOLEINTERFACE
Thankx
|
|
|
|
|
Please provide some more info what you mean. If i go by my guess about what you mean, then no, you just need an IRichEdit pointer which will be set to the instance of the interface when EM_GETOLEINTERFACE returns, as the documentation[^] says.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Hi,
I do the SendMessage EM_GETOLEINTERFACE
in my ::OnInitDialog right after I instantiate
my CRichEditctrl via new
I saw an example on the Codeproject by
Mike O'Niell
for IRichEditOleCallback he instantiates a copy
e.g.
Interface IExRichEditOleCallBack : public IRichEditOleCallback
{
}
on the heap before setting the address inthe SetOLECallBack
was wondering if the same was true for IRichEditOle
Thankx
|
|
|
|
|
I see. Well, in case of the IRichEditOleCallback, as the documentation[^] states, you are responsible to provide an implementation of the interface methods, this is probably why the exsample creates IExRichEditOleCallBack (from IRichEditOleCallback) and feeds that to the rich edit control. He provides implementations of methods that will be called "by the rich edit" (or somesuch) allowing him to execute his specialized code when something needs to be done.
When you query for the IRichEditOle interface, its methods are already implemented, you don't need to make your own instance of it since what you want to do is to use the already impelemented functionality.
I hope this is understandable rather than making things seem to be even more complicated than before.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
had my code in the Wrong Place put it in ::OnInitDialog after I connect my CRicheditctrl to the resource item via DDX_CONTROL
BTW I am a Madgar my parents were born in Debrcin
can speak Hungrian but obviously not write....
|
|
|
|
|
"Magyar" és "Debrecen", i live in Debrecen too.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
I want to add listview to my MFC(.net2003) application interface.
any have simples or some links to help hoe to add the data to listview
and how to sort, get the selected item!.
i need also to add to the form a toolbar with icons. please help
|
|
|
|