|
If the functions have the same name but they get different parameters... only the function that fits the parameters should be called.
Function (int Par1, CString Par2);
Function (double Par1, int Par2);
is not possible to call both at once although they have the same name.
If both functions get the same number and typ of parameters, in the same order... then let's wait to another explanation from the high level users and I will learn it as well
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hope you are aware of run time polymorhism.
Keep the same name function/method as virtual function in the base class. For the derived class object pointer allocate the corresponding base class (whose function needs to be invoked) then call the function resulting the corresponding base class get invoked. See below to make things clear
class A
{
public:
virtual void show(){cout<<"Class A invoked"};
}
class B
{
public:
virtual void show(){cout<<"Class B invoked"};
}
class C: public A, public B
{
}
main()
{
C* ptr = new A;
ptr->show();
C* ptr1 = new B;
ptr1->show();
}
|
|
|
|
|
Muhammad Zeeshan wrote: A class is inheritting from 2 base classes and both the base classes have a function/method with the same name.
The class structure is as follows?
Base1 Base2
\ /
\ /
\ /
Derived
If this is the class structure, then its not a classic C++ diamond problem.
Muhammad Zeeshan wrote: From the object of the child class how we can call a function of the one base class.
Just prefix the base class name before the call. See the code snippet.
Derived DerivedObject;
DerivedObject.Base1::CommonFunction();
Derived* pDerivedObject = new Derived;
pDerivedObject->Base1::CommonFunction();
Does this solve your problem? Or is it something else?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Use virtual public for deriving classes.
|
|
|
|
|
scope resolution operator [::]
"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/codeProject$$>
|
|
|
|
|
hi
what is the possible ways to link two diallog boxes together.
i mean if i press a button in dialog A it would move to dialog B.
i had problems with this ..espically if i used a bitmap dialog rather than CDialog...
any suggestions...
reealy ..any kind of help will be appriciated
thank u all
|
|
|
|
|
Do you want to move the button from one dialog to another? Or the whole content from one dialog to another?
If the first one (by the second is also a way to do it) you have more than one possibility. The most dinamicall is to create the controls dinamically hen and where you need them. The other one with less code to implement is to create the button in both dialogs and just make them visible or invisible when you need it, in example:
m_LocalButton.ShowWindow (FALSE);
pOtherDialog->m_button.ShowWindow (TRUE);
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
thank u for ur reply
actually what i mean is how to call one dialog from the other ... lets say for example ..if i have any kind of operation in one dialog and the result should appear on another dialog ...so what i need exactly is with a press of a button ...the next dialog appear(pop up) or whatever u wanna call it...
i appriciate ur help
thank u
|
|
|
|
|
lahom wrote: if i have any kind of operation in one dialog and the result should appear on another dialog
Then just call the other dialog when you press in the button in either Modal or Modalless way (according to your needs), but for both... once you have called it you can access its public variables, so if you want to send anything to the second dialog, you have to have a variable/struc/class or whatever you need fitting it there.
One basic example:
OnPressButton ()
{
CSecondDialog myDialog;
myDialog.m_varResult = your_calculation_result;
int nReturn = myDialog.DoModal ();
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
ok
this works pretty good on a dialog based on CDialog..
I am creating a dialog based on class named: CBitmapDialog..
if I use this way of DoModal()…its not working properly
so what can I do about this … is there any other ways???
thank u
|
|
|
|
|
Modalless call of dialogs. There already are some answers for that here in forum.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Trying to connect (Open) to database with connection string retrieved using GetConnect.
I get an error message telling me that the Open failed, but the file path is different than the one I sent in Open function.
My application and database are in different subdirectories and it should not be a problem.
Could this be an ODBC problem? Perhaps I need new ODBC driver version?
I am running VC6.0 with Access 2000 and no, upgrading to anything else is not an option. Please refrain from comments like that.
Here is the code snippet:
// build database
m_CFD2008Doc->m_pFDDatabase = new CDatabase();
VERIFY(m_CFD2008Doc->m_pFDDatabase );
// set connect string
CString strConnect =
"ODBC;DSN=MS Access Database;DBQ=K:\0 FD2008\Database\db2.mdb;DefaultDir=K:\0 FD2008\Database;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;";
if(! m_CFD2008Doc->m_pFDDatabase->Open(NULL,FALSE,FALSE, strConnect,TRUE ))
{
TRACE(" Failed to open %s database ", strConnect);
}
Error message received:
Could not find file "K:\0 FD2008\V1\FD2008\.mdb"
Thanks for your help
Vaclav
PS Why is this editor having problem accepting dereference symbol "->" in text?
A dummy fell for the oldest trick in C not including double \\ in the string. Also the last parameter in Open must be FALSE.
<div class="ForumMod">modified on Sunday, May 25, 2008 12:48 PM</div>
|
|
|
|
|
Did you try "\\" in string literal instead of "\" ?
|
|
|
|
|
Thanks, feel like an idiot for falling for the oldest trick in the C programming!
Now I get that my ODBC driver does not support dynasets!
And this is Access 2000 ! I hope I can fix that.
Thanks again.
Vaclav
|
|
|
|
|
|
Real nice article.
I think I got the access (Open) figured out now I am struggling with writing to database. Getting Invalid descriptor index and it is driving me nuts to figure it out.
The books say do AddNew, do your ads and then Update for dynaset.
But it keeps failing with this cryptic error. Something about columns numbers not proper.
But it fails on first add!
Vaclav
|
|
|
|
|
That's pretty much much it...
pMyRecordset->AddNew();
pMyRecordset->m_sColumn1="SomeData1";
pMyRecordset->m_sColumn2="SomeData2";
pMyRecordSet->Update();
How are your recordsets bound? Did you use the wizard to bind them or are you attempting to dynamically bind them?
|
|
|
|
|
I used wizard to initially build the CRecorset class and when I change field I use Update Columns and Bind All.
What bugs me - I have no feedback during Bind All and the button stays active - does not return back to "normal". So I really do not understand or see what is happening.
I vaguely remember similar problem and it had to do something with column order. There are few reference on the internet to that effect. But it does not make sense - since it fails same way if I select individual columns or just do SELECT *...
My last attempt is to use single column table and see if I can make it work.
There is something simple and stupid missing.
Vaclav
|
|
|
|
|
I was able to reproduce the "invalid descriptor index" by messing up my column index alignments in the "DoFieldExchange" and Constructor sections of my recordset class.
I'm not sure if that helps you find the problem but for what it's worth.
|
|
|
|
|
I think you found it. Me being old - today is my 65 b-day - I just did not remember the details.
Vaclav
|
|
|
|
|
Happy Birthday!
|
|
|
|
|
I thing the problem was MFC arranged the dx stuff alphabetically!
|
|
|
|
|
Interesting.
Which version of MFC or Visual C++ are you using by the way? (Just out of curiousity)
|
|
|
|
|
Look up CRecordset::m_nFields in MSDN.
It describes the column alignment requirements
|
|
|
|
|
Using VC++ 6.0 and I think the MFC is still 4.0.
Yes, I did run into this few years back.
Today I'll build a test app with just single table and one field ( if there is such a thing!) and do some testing.
In theory it should work with just one variable.
On a side note - since I am no SQL expert - why does CRecordset rejects
"SELECT ALL FROM table" but it likes "SELECT * FROM table"?
Apparently terms "column", "field" and this darn descriptor index are blood relatives.
Vaclav
|
|
|
|