moteutsch 0 Newbie Poster 16 Years Ago How can I clone an object in C++, so it is a seperate object, but exactly the same as the original? Thanks, - Moshe c c# c++ 0 0 Reply with Quote Share Recommended Answers Collapse Answers Answered by William Hemsworth 1,339 in a post from 16 Years Ago You can use the default copy constructor, like this: Copy to Clipboardstruct myObject { int data[10]; }; int main() { myObject a; /* Do stuff to 'a' */ myObject b( a ); /* 'b' is identical to 'a' now */ return 0; } Jump to Post All 2 Replies William Hemsworth 1,339 Posting Virtuoso 16 Years Ago You can use the default copy constructor, like this: Copy to Clipboardstruct myObject { int data[10]; }; int main() { myObject a; /* Do stuff to 'a' */ myObject b( a ); /* 'b' is identical to 'a' now */ return 0; } 1 0 Reply with Quote Share tux4life commented: Absolutely right :P +3 moteutsch 0 Newbie Poster 16 Years Ago Thanks for the prompt and informative response! - Moshe 0 0 Reply with Quote Share Share Facebook Twitter LinkedIn Reply to this topic Be a part of the DaniWeb community We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge. Sign Up — It's Free!
William Hemsworth 1,339 Posting Virtuoso 16 Years Ago You can use the default copy constructor, like this: Copy to Clipboardstruct myObject { int data[10]; }; int main() { myObject a; /* Do stuff to 'a' */ myObject b( a ); /* 'b' is identical to 'a' now */ return 0; } 1 0 Reply with Quote Share tux4life commented: Absolutely right :P +3
moteutsch 0 Newbie Poster 16 Years Ago Thanks for the prompt and informative response! - Moshe 0 0 Reply with Quote Share