Click here to Skip to main content
15,888,286 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: [win32]Draw on a background bitmap Pin
Member 296547126-May-11 12:07
Member 296547126-May-11 12:07 
GeneralRe: [win32]Draw on a background bitmap Pin
Mark Salsbery26-May-11 12:11
Mark Salsbery26-May-11 12:11 
AnswerRe: [win32]Draw on a background bitmap [modified] Pin
Mark Salsbery26-May-11 13:57
Mark Salsbery26-May-11 13:57 
AnswerRe: [win32]Draw on a background bitmap Pin
bob1697228-May-11 18:59
bob1697228-May-11 18:59 
QuestionUsing streams Pin
Berlus26-May-11 2:40
Berlus26-May-11 2:40 
QuestionRe: Using streams Pin
David Crow26-May-11 2:49
David Crow26-May-11 2:49 
AnswerRe: Using streams [modified] Pin
Stefan_Lang26-May-11 3:01
Stefan_Lang26-May-11 3:01 
GeneralRe: Using streams Pin
Berlus26-May-11 10:05
Berlus26-May-11 10:05 
Thanks for the quick response.

Is there a way to insert the "serialization" code into the struct itself ? something like:

#include <iostream>
#include <fstream>
using namespace std;


struct MyStruct
{
	ostream& operator<<(ostream& output) {
		output << "    a: " << a << endl;
		output << "    b: " << b << endl;
		return output;
	}

	int a;
	double b;
};

int main(void)
{
  MyStruct ms;
  ms.a = 5;
  ms.b = 4.2;

  cout << ms;

  // Write to a file without changing methods in MyStruct
  ofstream  my_file("me.txt");
  my_file << ms;
  
  return 0;
}

I tried it, and got compilation errors.

IntelliSense: no operator "&lt;&lt;" matches these operands

I am trying to create some sort of a generic ToString.

Thanks,
Berlus
GeneralRe: Using streams Pin
Stefan_Lang26-May-11 21:14
Stefan_Lang26-May-11 21:14 
QuestionProblem opening URL Pin
pix_programmer26-May-11 1:44
pix_programmer26-May-11 1:44 
AnswerRe: Problem opening URL Pin
Richard MacCutchan26-May-11 1:53
mveRichard MacCutchan26-May-11 1:53 
GeneralRe: Problem opening URL Pin
pix_programmer26-May-11 1:58
pix_programmer26-May-11 1:58 
GeneralRe: Problem opening URL Pin
Richard MacCutchan26-May-11 2:59
mveRichard MacCutchan26-May-11 2:59 
GeneralRe: Problem opening URL [modified] Pin
pix_programmer26-May-11 3:20
pix_programmer26-May-11 3:20 
GeneralRe: Problem opening URL Pin
Richard MacCutchan26-May-11 3:32
mveRichard MacCutchan26-May-11 3:32 
AnswerRe: Problem opening URL Pin
Niklas L26-May-11 4:49
Niklas L26-May-11 4:49 
GeneralRe: Problem opening URL Pin
pix_programmer26-May-11 20:32
pix_programmer26-May-11 20:32 
GeneralRe: Problem opening URL Pin
Niklas L26-May-11 21:40
Niklas L26-May-11 21:40 
GeneralRe: Problem opening URL Pin
pix_programmer26-May-11 22:15
pix_programmer26-May-11 22:15 
QuestionRe: Problem opening URL Pin
Niklas L27-May-11 1:09
Niklas L27-May-11 1:09 
QuestionFindWindow() without giving Application windows caption Pin
manju 326-May-11 0:44
manju 326-May-11 0:44 
AnswerRe: FindWindow() without giving Application windows caption Pin
tagopi26-May-11 1:33
tagopi26-May-11 1:33 
AnswerRe: FindWindow() without giving Application windows caption Pin
ThatsAlok26-May-11 21:39
ThatsAlok26-May-11 21:39 
Questionendtask program using win32api/c like taskmanager to close programs without invoking taskmanager just in one shot Pin
Jayapal Chandran25-May-11 20:52
Jayapal Chandran25-May-11 20:52 
AnswerRe: endtask program using win32api/c like taskmanager to close programs without invoking taskmanager just in one shot Pin
_AnsHUMAN_ 25-May-11 21:53
_AnsHUMAN_ 25-May-11 21:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.