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

C / C++ / MFC

 
GeneralRe: Windows Explorer Pin
Peter Molnar15-Nov-03 14:51
Peter Molnar15-Nov-03 14:51 
GeneralRe: Windows Explorer Pin
harsh91115-Nov-03 19:24
harsh91115-Nov-03 19:24 
GeneralRe: Windows Explorer Pin
Prakash Nadar15-Nov-03 19:51
Prakash Nadar15-Nov-03 19:51 
GeneralHTML default document icon Pin
alex.barylski15-Nov-03 8:40
alex.barylski15-Nov-03 8:40 
GeneralRe: HTML default document icon Pin
Peter Molnar15-Nov-03 14:28
Peter Molnar15-Nov-03 14:28 
GeneralRe: HTML default document icon Pin
alex.barylski15-Nov-03 14:38
alex.barylski15-Nov-03 14:38 
QuestionHow to duplicate an object? Pin
Atlence15-Nov-03 7:46
Atlence15-Nov-03 7:46 
AnswerRe: How to duplicate an object? Pin
Jeryth15-Nov-03 8:15
Jeryth15-Nov-03 8:15 
Something along the lines of
*pMyVar2 = *pMyVar1;


I just made a simple program that does the same thing and it works.

#include <iostream>
using namespace std;


class Class1
{
public:
	int var1;
	int var2;
};

int main()
{
	Class1 * object1 = new Class1();
	Class1 * object2 = new Class1();

	object1->var1 = 1;
	object1->var2 = 3;

	object2->var1 = 2;
	object2->var2 = 4;

	cout << "Object1 Var1 = " << object1->var1 << endl;
	cout << "Object1 Var2 = " << object1->var2 << endl;
	cout << "Object2 Var1 = " << object2->var1 << endl;
	cout << "Object2 Var2 = " << object2->var2 << endl << endl;

	*object2 = *object1;
	cout << "Object2 Var1 = " << object2->var1 << endl;
	cout << "Object2 Var2 = " << object2->var2 << endl;

	delete object1;
	object1 = NULL;
	delete object2;
	object2 = NULL;

	system( "pause" );
	return 0;
}


object2 was switched in the output so I don't know why it wouldn't work for a more complicated class.

The question "Do computers think?" is the same as "Can submarines swim?"
DragonFire Software

Jeryth
AnswerRe: How to duplicate an object? Pin
Tim Smith15-Nov-03 8:18
Tim Smith15-Nov-03 8:18 
GeneralRe: How to duplicate an object? Pin
Jeryth15-Nov-03 8:27
Jeryth15-Nov-03 8:27 
GeneralRe: How to duplicate an object? Pin
Anonymous15-Nov-03 9:17
Anonymous15-Nov-03 9:17 
GeneralMFC serialization fails from COM Pin
DimkaSPB15-Nov-03 7:44
DimkaSPB15-Nov-03 7:44 
GeneralChat Server&amp;Client Protocol + how2tx/rx question?! Pin
[ Jûroehn ]15-Nov-03 7:35
[ Jûroehn ]15-Nov-03 7:35 
GeneralRe: Chat Server&amp;Client Protocol + how2tx/rx question?! Pin
Peter Molnar15-Nov-03 14:07
Peter Molnar15-Nov-03 14:07 
GeneralDirectShow (DirectX) on CD Pin
TFB15-Nov-03 7:32
TFB15-Nov-03 7:32 
GeneralRe: DirectShow (DirectX) on CD Pin
Jeryth15-Nov-03 8:23
Jeryth15-Nov-03 8:23 
GeneralRe: DirectShow (DirectX) on CD Pin
TFB15-Nov-03 10:41
TFB15-Nov-03 10:41 
GeneralProblems with PI Pin
Jeryth15-Nov-03 7:08
Jeryth15-Nov-03 7:08 
GeneralRe: Problems with PI Pin
Kevin McFarlane15-Nov-03 10:13
Kevin McFarlane15-Nov-03 10:13 
GeneralRe: Problems with PI Pin
Antti Keskinen15-Nov-03 15:02
Antti Keskinen15-Nov-03 15:02 
GeneralJust bought a PocketPC, however, I need help here. Pin
Link260015-Nov-03 3:21
Link260015-Nov-03 3:21 
GeneralRe: Just bought a PocketPC, however, I need help here. Pin
Mike Dimmick15-Nov-03 3:32
Mike Dimmick15-Nov-03 3:32 
GeneralMultithreaded TCP server, client thread termination Pin
Kuniva15-Nov-03 2:14
Kuniva15-Nov-03 2:14 
GeneralRe: Multithreaded TCP server, client thread termination Pin
Rickard Andersson2015-Nov-03 2:41
Rickard Andersson2015-Nov-03 2:41 
GeneralRe: Multithreaded TCP server, client thread termination Pin
Kuniva15-Nov-03 3:31
Kuniva15-Nov-03 3:31 

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.