|
printf is not typesafe or extensible, whereas cout is. This means that C++ output is easier to get right (once you get over the odd syntax), and the output of complex objects can be deferred into those objects, thus improving encapsulation. However, printf can be handy for quick apps, and most programmers seem to prefer "format string" based IO (such as printf) to "stream oriented" IO (such as cout). Hence why everyone uses sprintf to construct strings, even though stringstream objects are safer
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Added to that, positional format strings, as supported by Windows' FormatMessage (and .NET's String.Format ) are easier to translate for localized versions of the software.
cout doesn't have an answer to this.
I'll admit that since I mostly write C++ software for Pocket PCs, I don't often have the chance to use the C++ runtime library, because most of it's missing.
|
|
|
|
|
|
Ian Darling wrote:
Hence why everyone uses sprintf to construct strings, even though stringstream objects are safer
sprintf is convenient but we really ought to shun it for the reason you say. In the past I've run into nasty memory bugs in maintenance because of developers' fondness for sprintf.
Kevin
|
|
|
|
|
Guys,
I have noticed - CHtmlView sometimes does not process correctly if form does not have submit button, Enter key does not submit.
This form will work perfectly - submit on Enter key:
<br />
<form name="myform" onSubmit="return cmd();" ><br />
<input type="text" class="form-say" name="say"><br />
<input type="submit" class="form-say" name="say" ><br />
</form>
And this one will just ignore Enter key (but in IE works fine):
<br />
<form name="myform" onSubmit="return cmd();" ><br />
<input type="text" class="form-say" name="say" ><br />
</form>
Do you know the way to work around it?
Thanks
PS - I'm using MFC with good old VC++ 6.0 . Maybe is it fixed in newer versions ?
|
|
|
|
|
Maybe some JavaScript that does the Submit, or a hidden Submit button, assuming that is possible.
PS. I don't thing this is a CHtmlView issue.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Maybe some JavaScript that does the Submit, or a hidden Submit button, assuming that is possible.
PS. I don't thing this is a CHtmlView issue.
The problem is - I'm writing multy-window browser, so I have to process pages "as is", and this particular example - part of IRC:CGI, so I have to work with "submit-less" forms correctly.
I believe it is CHtmlView issue (not mine), because I've created simple Document/View CHtmlView-based project by wizard, and opened test "submit-less" page without any code modification - same result - it does not sumbit.
|
|
|
|
|
trof wrote:
I believe it is CHtmlView issue (not mine), because I've created simple Document/View CHtmlView-based project by wizard, and opened test "submit-less" page without any code modification - same result - it does not sumbit.
This doesn't surprise me. Why not modify the HTML after it is loaded. ie. in xxx::OnDocumentComplete().
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi to all. I'm trying to programm Macromedia's Flash ocx under Visual C++. It is known that this control cannot support transparent background. But there are in the market third party programms that enable transparency in the control. Can give me a help how to make transparent the background of the control?
Thank's bros.
|
|
|
|
|
hi...
can u pls tell me how to get the handle of DLG from a totally different class???
i have a class that does some function and then at tat point i need to access my main dialog....actually i need to access a static control of that dialog...
can anyone pls tell me a solution???
tks a lot
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
can anyone gimme an answer??
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
When your dialog is created, store its class instance in a static member variable in the dialog class. Create a static function that returns that instance.
So, if your dialog class was named CDlg, then to get the dialog, you could do:
CDlg* dialog;
dialog=Dlg.GetMainDialog();
HTH
"To know what is right and not do it is the worst cowardice." -- Confucius
FLUID UI Toolkit
|
|
|
|
|
my dialog and my class are far far away...
my dlg calls a class by returning ans int to ir(this class is not a dlg)
then this class has to call another class..
this another class needs to access the dilog...
now can i pass the dlg to the class as the class is created by returning a valu..
and C++ only allows returning one param...
I HAVE TO USE RETURNING to to create the class...
so i cant substitute it with anything else
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Joseph R. Thomas wrote:
my dialog and my class are far far away...
The method I showed you works as long as the other class is in the same process as the dialog class.
The other thing you can do is pass the class in the method:
Dialog calls class, passing instance of itself to the class.
Class calls class 2, passing the dialog instance that was passed to it.
Class 2 calls the dialog instance that was passed to it.
"Love does not delight in evil but rejoices with the truth." -- 1 Corinthians 13:6
FLUID UI Toolkit
|
|
|
|
|
Dialog calls class, passing instance of itself to the class.
Class calls class 2, passing the dialog instance that was passed to it.
Class 2 calls the dialog instance that was passed to it.
can u gimme a example of thow to do that???
tks
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Suppose the method you wanted to call in the first class was called DoSomething(CDlg dialog), the method you wanted to call in the second class was DoSomething2(CDlg dialog), and the method to be called in the dialog was called CallDialogMethod. The code below would do what you wanted:
class1.DoSomething(this);
class2.DoSomething2(dialog);
dialog.CallDialogMethod();
You might consider buying some books on programming in C++. They'll help you with this type of thing.
""It is impossible to rightly govern the world without God and the Bible." -- George Washington
FLUID UI Toolkit
|
|
|
|
|
NVM...
u get get my meaning....
all you re telling me to do is stuff i know already...
that means if i posting this here...
its definetly not the kiddy stuff....
you are telling me the basics....
but then...
maybe i never phrased my qestion properly...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
OK, maybe you can try to explain it better - give me more details - and then maybe I can help you.
"Going to church doesn't make you a Christian any more than going to the garage makes you a car." -- Laurence J. Peter
FLUID UI Toolkit
|
|
|
|
|
Dear All
It would be great if anyone could tell me how to print using cximage?
How do i go about incorporating it?
Thanks
|
|
|
|
|
Dear all
I am desperately trying to print a jpeg/bmp image in vc++.
It prints it on the top left corner of the page ina very small size.
I used the mm_loenglish mapping mode.
It would be great if you could help me to fix this.
Thankyou very much for your time.
|
|
|
|
|
I have an abstract base class CFoo that contains a pure virtual method void setDefault() as well as a public static method void doSomething() , like so:
class CFoo {
public:
CFoo()
{ setDefault(); }
virtual ~CFoo()
{}
virtual void setDefault() = 0;
static void doSomething() {
int x = 0;
x = 32;
}
}
One of CFoo 's clients does this:
CFoo::doSomething();
which causes VC6's linker to complain that CFoo::setDefault() is not implemented. It's as if the compiler wants to construct a CFoo object (which makes no sense since it's an abstract base class).
Is it me or VC6? (It's probably me, but I can't figure out what I'm doing wrong).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I think it is VC6. Both VC7.1 and Comeau compiled it just fine.
The results I get from Comeau,
MODE:strict errors C++
"ComeauTest.c", line 7: warning: call of pure virtual function
setDefault();
^
"ComeauTest.c", line 16: warning: variable "x" was set but never used
int x = 0;
^
In strict mode, with -tused, Compile succeeded (but remember, the Comeau online compiler does not link).
http://www.comeaucomputing.com/tryitout/[^]
|
|
|
|
|
Thanks.
What's weird is, I went ahead and implemented CFoo::setDefault() keeping the pure virtual specifier, and guess what - VC6 didn't complain! Eeek! (Nor did the problem go away.)
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
If no one actually attempts to instantiate a CFoo object, then it won't complain.
If you just do:
CFoo fred;
it will.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Actually, you can never instantiate a CFoo , since it's an abstract class.
The problem has to do with the fact that CFoo's static (factory) method was constructing a derived class which caused the linker to want to resolve CFoo::setDefault() . This is sorta hokey, but what I was doing was wrong, since the derived class's vtable has not been initialized in the base class' constructor.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|