|
On my recursive function, I made a mistake:
GabyGirl wrote:
int z=powerRECURSIVE(n,m)*powerRECURSIVE(n,m);
if(k && 1)return z*n;
return z;
I meant [BITWISE AND]
if(k&1) return z*n;
excuse the inconvenience....
GabyGirl
|
|
|
|
|
Where is this program in n lg n ?
I think the main point here should be the calculation by multiplication, but your function gets the base as n ?
So isn't it in O(1) considering n ?
When I look at k it's already in O(lg k). Everytime the recursive function is called m=k>>1 makes the new exponent 1/2 the size. So it should be in O(lg k)
If you think that it is in O(k lg k) because of the times that you measured, then it's just because of the line that Joaquin already pointed out.
WIthout that correction you'd win nothing, because the function does get called twice calculating the same result twice.
|
|
|
|
|
I was wondering I see many registry classes and such for to write to registry, read registry, ect. However I have never seen any code on how to search the registry for differn't values like lets say I wanted to search tne enitre registry for a key name or specific data how would you go about doing that?
- LiquidKnight
|
|
|
|
|
When you record a CD on a CD-R, the cd gets a serial number which changes from one to another.
Is there a way to copy/image/duplicate a CD with the same serial number?
Regards,
Sassan
|
|
|
|
|
I hope you're not trying to pirate something.
CloneCD will do it. google.
#include <beer.h>
|
|
|
|
|
Hello,
I've to use a callback function in my project:
VOID WINAPI RasDialFunc(UINT unMsg, RASCONNSTATE rasconnstate, DWORD dwError);
I wanna know can i define it as member function for a dialog ?
In fact i wanna use some dialog's member variables inside the callback function ...
What's your idea ?
Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hadi,
A member function cannot be a Callback function since it should have a global scope
|
|
|
|
|
The callback function must be declared in the class as static , in order not to receive the implicit this argument. This makes the class members inaccessible from the member function unless you pass the this pointer as an argument. Looking at your function, I can see no eligible argument... But this is by no means impossible. I have done it before.
|
|
|
|
|
But this is by no means impossible
You means: we can pass this even if the functions have no available for it ?????
Ex: static void CallbackA(UINT nMsg)
Can you call:
CallbackA(WM_...,this);
?????
I'm a Vietnamese student
|
|
|
|
|
No, I mean that usually API callback functions have an LPVOID argument that may be used for this. If I understood your question, you meant API callback functions, right?
|
|
|
|
|
If you need access to the member functions you can also declare a static pointer of the class' type and assign it the this pointer.
class Foo {
public:
Foo () { this_ = this; }
void Bar () { ... }
static MyCallBack ( ... ) {
this_->Bar ();
}
private:
static Foo * this_;
}
|
|
|
|
|
I don't know about your callback function. But commonly, we usually pass 'your dialog' pointer as a function's parameter. With this pointer, we can access everything in your dialog.
But in your callback function, where is input parameter ?
I'm a Vietnamese student
|
|
|
|
|
I am creating a DialogBar, however I have to assosiate the DialogBar resource with the View Class because it needs to be able to access data members from the view. however now I have a problem.. I need to be able to figure out how to retrive the m_wndDlgBar data member from the frame. so I can add code in my view as such
CSliderCtrl* pSlide = (CSliderCtrl*)m_wndDlgBar.GetDlgItem(IDC_DIALOG_BAR);
any help would be appreciated
|
|
|
|
|
There are several solutions. One solution is to class a function in view. Another solution is messages.
Kuphryn
|
|
|
|
|
Can you give a little more detail on either method.
I tried creating a public function in CMainFrame such as
CToolBar& GetToolBar(){return m_wndToolBar;}
then tried to access CMainFrame::GetToolBar()
but of course that didn't work..
|
|
|
|
|
One solution to accessing main frame is AfxGetMainWnd().
Kuphryn
|
|
|
|
|
I thought of that is well, but AfxGetMainWnd() does not give me access to the toolbars or statusbars.
|
|
|
|
|
I have Doc/View application.
Upon one user command I create thread passing some user-defined data to it.
This is the thread procedure:
UINT ThreadLocalCopy(LPVOID pParam)
{
___THREAD_COPY_PARAM* p_info = (THREAD_COPY_PARAM*)pParam;
___BYTE type = 0;
___DlgLocalCopy::LocalFolderCopy("", type, p_info);
___// finish operation
___::SendMessage(p_info->h_wnd, WM_THREADFINISHED, 0, 0);
___return 0;
}
And here's DlgLocalCopy::LocalFolderCopy() funcion, which is called from the thread above:
void DlgLocalCopy::LocalFolderCopy(LPCTSTR pth, BYTE &type, THREAD_COPY_PARAM *p_param)
{
___DlgOverwrite1 dov;
___DlgGetText dgt;
___DlgExpandSelection ds;
___CFileFind fff;
___CMainFrame* mf = (CMainFrame*) AfxGetApp()->GetMainWnd();
___CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument();
___.
___.
___.
}
But calling CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument()
fails in CWnd::AssertValid()
on this line:
ASSERT((CWnd*)p == this); // must be us
Why? I think that the stuff I am doing here is thread-safe, isn't it? I am not passing any CWnd objects to thread, I just call
AfxGetApp()->GetMainWnd()->GetActiveDocument()
inside the thread and it is not forbidden, is it?
Or if it is, how to achieve it another (safe) way?
Any help would be gratefully appreciated.
Standa.
|
|
|
|
|
MFC's handle maps are maintained on a per thread basis, so from your worker thread AfxGetApp()->GetMainWnd() won't work. One solution is to pass CMyDoc* to your thread creation function. Also it isn't a good idea to use SendMessage() from a thread, use PostMessage() instead or Events. Have a read of the Threading articles here on CP.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hello
I need a view class that can show formatted text with pictures, tables and font colors in two columns (MSWord-like with text flowing from one column to another) with page divisions.
It can be read-only, but with copy operation support.
I was adviced that I can use PDF format in some way.
Can anyone help me with at least a starting point to look for info - some MFC classes, custom controls or articles and sites in inet?
Thank you in advance
|
|
|
|
|
Trying to retrieve CPU temperature, HDD temperature, information in my application. Does there exists some sort of BIOS wrapper class? Can anyone help me?
|
|
|
|
|
Hiya am getting a syntax error on using CREATE TABLE in SQL and an Access database:
// open the database
database.Open( NULL,false,false,sDsn );
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(10) ) ");
Does anyone know what is wrong with the ExecuteSQL line..
Thanks
grahamoj.
|
|
|
|
|
Hiya again, I found out my problem. Missing comma i.e
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4),OfficeName TEXT(10) ) ");
So now what I need to be able to do is make the text field 600 chars. So tried these:
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(600) ) ");
and
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) ");
but it won't create the table because text fields are too long..
any ideas on how to do this??
grahamoj.
|
|
|
|
|
I have an SDI application, in which my CView inherits from CScrollView.
I display a bitmap on the view window (576X768). I redraw this bitmap every 1 second.
The problem is: when I move the scroll bar, the redraw of the bitmap resets the scroll position. What message I need to catch, or what function I can overload in order to handle this problem?
|
|
|
|
|
Your code that draws the bitmap needs to take into account the current scroll position when displaying the bitmap:
int x = GetScrollPos(SB_HORX);
int y = GetScrollPos(SB_VERT);
If you treat these values as -ve destination plot position when drawing the bitmap, it should show correctly.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|