|
I have done it that way but according to samples I've found in Internet, it has to be possible to do it with overloading << but I cannot get it to compile.
|
|
|
|
|
Cristoff wrote: I've found in Internet
can i know this place ?
Cristoff wrote: but I cannot get it to compile.
any chance to have a look at your "not-compiling" code (i don't want it all, i need only a piece of code to understand how you try to achieve the point we're talking about) ...?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
Thank you very much for wanting to help me. The problem is that I've deleted it yesterday and I cannot find it now, although I'm searching it yet for my own needs.
If I find it, I'll post it later.
Thank you!
|
|
|
|
|
I don't understand how varargs fits into overloading << ?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
VivekuniQ wrote: is it really possible to overload a ">>" ??
this is not what we're talking about, but to answer your prompt question, yes it is !!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
#include "stdafx.h"
#include <string.h>
#include <iomanip.h>
#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
class Employer
{
friend ostream &operator <<(ostream &Obj, Employer &EmpObj) ;
private :
public:
Employer()
{
//strcpy(m_name,"Amol Ravatale");
}
~Employer()
{
}
char m_name[20];
};
ostream &operator <<(ostream &Obj, Employer &EmpObj)
{
Obj<<empobj.m_name ;
="" return="" obj="" ;
}
istream="" &operator="">>(istream &obj, Employer &EmpObj)
{
char str[30];
obj>>str;
strcpy(EmpObj.m_name ,str);
return obj;
}
int main(int argc, char**argv)
{
Employer emp;
ofstream man("amol.txt") ; //creates a text file in application path
strcpy(emp.m_name,"amol");
man<<emp; writes="" data="" to="" file
="" man.close()="" ;
="" cout<<emp.m_name="" ;="" shows="" at="" conssole
="" man="">>emp;
//cout<
|
|
|
|
|
sorry , include these files
#include "stdafx.h"
#include <string.h>
#include <iomanip.h>
#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
|
|
|
|
|
Here is basically what I'm trying to do:
<br />
#include <iostream><br />
#include <fstream><br />
<br />
<br />
class Logger<br />
{<br />
public:<br />
static Logger &GetInstance()<br />
{<br />
static Logger logger;<br />
return logger;<br />
};<br />
<br />
void Initialize()<br />
{<br />
if (!Log.is_open())<br />
Log.open("logfile.txt");<br />
};<br />
<br />
void Shutdown()<br />
{<br />
if (Log.is_open())<br />
{<br />
Log.close();<br />
}<br />
};<br />
<br />
<br />
<br />
protected:<br />
Logger()<br />
{<br />
};<br />
std::ofstream Log;<br />
<br />
public:<br />
template <typename T><br />
friend std::ostream & operator << ( std::ostream & os, T data );<br />
};<br />
<br />
template <typename T><br />
std::ostream & operator << ( std::ostream & os, T data )<br />
{<br />
os << data;<br />
std::cout << data;<br />
return os;<br />
};<br />
<br />
int main()<br />
{<br />
std::cout << "Hello world!" << std::endl;<br />
Logger::GetInstance();<br />
Logger::GetInstance().Initialize();<br />
Logger::GetInstance()<< "ciao" << std::endl;<br />
std::cout << "Good nigght world!" << std::endl;<br />
return 0;<br />
}<br />
<br />
...but unfortunately I don't know what I'm doing.
|
|
|
|
|
It seems that CP likes eating #includes... of course I use: fstream and iostream.
|
|
|
|
|
Iam using VC++ as a fonrtend software to communicate with embedded system
through Serial communication(RS-232). Iam using Readfile and Writefile
functions to read and write through COM port. Can anyone Clarify me the
following,
* Is it necessary to Flush the Input and Output buffer for every command
being transmitted/received ???
* If not, how often should i Flush the input and output buffer ???
Madhu
|
|
|
|
|
Hello.
I think you should flush the buffers after every Writefile. Else, chances are that the data will remain in the write buffer. When you do a flush, the data will be sent to the device.
There is (generally) no need for flush before Readfile.
You might considder to search for a serial class. There are several here at CP. I have found them very useful over the years.
Kakan
|
|
|
|
|
hi,
can anybody tell me how to open most recent documents?
|
|
|
|
|
jayshml wrote: can anybody tell me how to open most recent documents?
Search RECENT folder for most recently open Documents
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
double click on it.
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
VivekuniQ wrote: double click on it.
Where ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I want to control data in my Combobox so that, if data I write is not inside my combobox the cursor must stay in the control. If data became exact the cursor can go anywhere.
I don't know how to block the cursor and to release it on the control.
What to do ?
I learn my self
-- modified at 7:18 Tuesday 6th December, 2005
|
|
|
|
|
You will probably have to derive a class from your combo box class, and handle messages when the control loses focus (WM_KILLFOCUS ) or gets deactivated (WM_ACTIVATE ), and deny leaving the control depending on where the user wants to go (I do not know if you would like to block the focus within your application or for the whole system).
~RaGE();
|
|
|
|
|
I want that the cursor stay within this control (ComboBox) because the data I write is wrong.(It is not in its data property)
I learn my self
|
|
|
|
|
C++ is not VB. as the previous answers said, you have to overload the event handler by yourself... WM_KILLFOCUS event occurs when the focus is about to leave from a control to another. there, you can make the tests and only if the content is validated, you call the base class (CWnd ) OnKillFocus() handler to allow it to process the focus change...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
How about sub-classing the CComboBox class, override the OnKillFocus message handler and set the focus to the combobox if the data is erroneous?
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
that's what I do
void Neworder::OnKillfocuscurrency()
{
CComboBox* pcpp = (CComboBox*)GetDlgItem(IDC_currency);
if (CB_ERR == pcpp->FindStringExact(-1,m_devise) )
{
pcpp->SetFocus();
}
else
{
}
}
I learn my self
|
|
|
|
|
Have you made sure that your handler is correctly mapped in the message map and that it actually gets called?
Set a breakpoint in the message handler and debug the application to find out whether your handler gets called or not and if it does verify that the statement pcpp->SetFocus() is executed.
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
I have automated MS word using VC++(MFC) version 6.0 . I create a MS Word Document. In this document i want to insert in the footer "2 of 12" format. Where 2 is the page number and 12 is the total number of pages. Please provide the solution for the same.
Thanking you.
|
|
|
|
|
Sachinpatole wrote: In this document i want to insert in the footer "2 of 12" format.
I think it's something like:
{ PAGE } of { NUMPAGES }
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|