|
while(cin>>english)
Remove this while loop and just do cin>>english as this is causing an infinite loop and not getting to your
cout<<"Would you like to have another sentence translated,?\n";<br />
cout<<"Type [Y] for yes and [N] for no:\n"; code.
Michael
The avalanche has started, it's too late for the pebbles to vote.
|
|
|
|
|
Can anyone tell me the basic difference b/w overloading and overriding ?? What i know is that overloading of operators in a class and overriding of functions in inheritance. Is there anything more ????
|
|
|
|
|
Overloading = more than 1 way to skin the cat. i.e. You can call the functions with different params.
overriding = using your class's functio instead of the virtual function from the base class.
If you want to get really cool, you can even have overloaded overrided functions! Or even override a virtual overloaded function...
...OK, i mean it, i'm going to bed now!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Right on, except that overriding doesn't require virtual functions.
class B
{
public: void foo(int x) { }
};
class D : public B
{
public: string foo(HWND h) { return "Bob"; }
}; D::foo() overrides B::foo() just by virtue of its name being the same.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Actually, overloading DOES require virtual functions.
What you've done is called function hiding.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
if i can remember correctly, and don't shoot me if i'm wrong, overloading means implementing functions of the base class of a class as is, while overriding means you alter and use a function of the base class.
|
|
|
|
|
I am declaring a class in a header file something like:
/////////////// headerfile A.h ////////////
#include "B.h"
class A
{
private:
B val;
// Blah
}
As can be seen above, i've declared a class 'A' in its header file. I've created an object of class 'B' as a private member of class 'A'.
Class 'B' also got a 'zero argument constructor'. As such will it be get called ??? How can i make sure that 'zero argument constructor' of class B, must be get called before i use it in any method of class A ???
|
|
|
|
|
when an object of type A is created, the constructors of all member variables will be called before A's constructor is called. try it.
class B
{
public:
B()
{
printf("B\n");
}
};
class A
{
public:
A()
{
printf("A\n");
}
B b;
};
main()
{
A a;
}
the output is :
B
A
-c
A | B - it's not a choice.
|
|
|
|
|
Can anyone direct me to the article that explains how to set up a radio button?
I found it somewhere a few months ago, but can't see to find it.
Or if you'd like you could explain to me how it is done. Part of it is setting the group on all the controls and the one before, or the control before and the last one are set to group...I just can't remember.
Thanks,
Jim
|
|
|
|
|
First make sure the radio buttons are arranged correctly in the tab order. (hit Ctrl+D in the dialog editor to set the tab order). The first button in the group must have the Group style set, all other must have it unset, and the first control after the last radio button must have it set. (So the Group style marks the end of the last group and the beginning of a new group).
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Please pardon the very newbie question, but....
I have two edit controls and an OK button in a dialog box. Edit1 is read only multiline and Edit2 is single line. What is the best way of appendin text from Edit2 into Edit1? I want to press Enter after entering text in Edit2, but I don't want to dismiss the dialog.
I added an invisible button, made it default, then put the copy and paste text in the OnButton1 handler, but that is a real kludge.
Once again, a very beginner question I know, but thanks to anyone who can help.
|
|
|
|
|
|
Hey all.
When asynchroniously downloading a file from an HTTP server, is it possible to receive INTERNET_STATUS_REQUEST_COMPLETE messages AFTER receiving an INTERNET_STATUS_CONNECTION_CLOSED message? Is it possible during a successful download, or only in a case of a failure?
Thank you!
|
|
|
|
|
Hi,
I want to draw a transparent bitmap into a dialogbar. There are exemples for drawing t. bitmap into dialog but none for dialogbar.
Anyone can help?
Everything's beautiful if you look at it long enough...
|
|
|
|
|
I have some void functions in my class
void B1(void);<br />
void B2(void) ; for which I type defined the following
typedef void EMPTYFUNC(void);
In a Thread Function I need to call these functions based on the value of a variable
UINT ThreadFunc(LPVOID p)<br />
{<br />
MyClass *thisPtr = (MyClass *)p;<br />
EMPTYFUNC *fPtr;<br />
switch(thisPtr->whichFunction)<br />
{<br />
case FIRST_FUNC : fPtr=thisPtr->B1;break;<br />
case ..<br />
<br />
}
I am getting an error at fPtr=thisPtr->B1
What am I doing Wrong ?
How should i call the function ?
Thanks
|
|
|
|
|
You need pointers to member functions, which resemble pointer to functions but have different syntax:
typedef void (MyClass::EMPTYMYCLASSMEMFUNC)(void);
UINT ThreadFunc(LPVOID p)
{
MyClass *thisPtr = (MyClass *)p;
EMPTYMYCLASSMEMFUNC *fPtr;
switch(thisPtr->whichFunction)
{
case FIRST_FUNC : fPtr=&MyClass::B1;break;
case ..
(thisPtr->*fPtr)();
} The syntax is admittedly weird. If you want to know more, search on some tutorial about "pointers to member functions".
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
i'm pretty new to this. i'm not even sure if "casting" is the term.
i need to take a string, convert it to an integer so i can do some math, then convert it back to a string to send out to a messagebox.
example:
int a;<br />
int b;<br />
int result;<br />
<br />
result=a+b;<br />
MessageBox(result); ideally a, b, and c would start out as a string, but i don't know how to convert so this might be a bad example.
|
|
|
|
|
Look in Mike Dunn's C++ FAQ[^] for methods to convert strings into numbers an vice versa.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm working on an MDI application and I wanted to do some custom handling for certain types of messages so I'm overriding the Run() function of my app like so:
<br />
int CMyApp::Run()<br />
{<br />
MSG msg;<br />
while(1)<br />
{<br />
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
{<br />
if(msg.message == WM_QUIT)<br />
break;<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
else<br />
{<br />
OnIdle(1);<br />
}<br />
}<br />
return msg.wParam;<br />
}<br />
This seems to work perfectly for some aspects since menus and the views for my documents are responding correctly to my mouse and keyboard events. However, all the ON_UPDATE_COMMAND_UI events for my toolbars have suddenly stopped receiving messages. What did I do wrong?
|
|
|
|
|
I don't know, but you can take a look at the source code of MFC (it is shipped with your Visual Studio) and know exactly how CWinApp::Run is implemented.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I don't see why you need to overide Run() and I can't recall seing anyone do this in an app. If you need to handle messages before they get processed by the MFC message maps then use PreTranslateMessage(). That's what I do in ED (see sig) which is an MDI app.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
I'm overriding Run() because the standard handling for WM_TIMER events is too slow for my needs so I'm adding my own timer-handling to Run() although I didn't show that part of the code here since it was irrelevant to my question.
As it turns out, the reason my Update UI events weren't being called was because those are called by OnIdle(0). I'm not sure why I used 1 there before; I think was confusing it with the Sleep() function.
|
|
|
|
|
Have you tried using the timer call back function instead of the timer message. Timers aren't all that accurate to begin with and may not be an appropriate way to achieve your task.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
hi. any body knows a way to bind GDIPLUS.DLL or something to include this file to .EXE project file ?
thnx
-=Ehsan-de-Burge=-
|
|
|
|