Click here to Skip to main content
16,005,734 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is it possible to make Visual Studio break whenever a given variable gets a specific value? Pin
jmkhael2-May-03 7:06
jmkhael2-May-03 7:06 
AnswerRe: Is it possible to make Visual Studio break whenever a given variable gets a specific value? Pin
Chris Meech2-May-03 7:15
Chris Meech2-May-03 7:15 
AnswerRe: Is it possible to make Visual Studio break whenever a given variable gets a specific value? Pin
Douglas Troy2-May-03 8:09
Douglas Troy2-May-03 8:09 
GeneralI can't display book and borrower's details Pin
grscot2-May-03 6:20
grscot2-May-03 6:20 
GeneralRe: I can't display book and borrower's details Pin
grscot3-May-03 3:28
grscot3-May-03 3:28 
GeneralGeneric C++ object/structure swap Pin
scottk@IntelligentSolutions.com2-May-03 5:27
scottk@IntelligentSolutions.com2-May-03 5:27 
GeneralRe: Generic C++ object/structure swap Pin
Rein Hillmann2-May-03 7:15
Rein Hillmann2-May-03 7:15 
GeneralRe: Generic C++ object/structure swap Pin
Gary R. Wheeler4-May-03 2:48
Gary R. Wheeler4-May-03 2:48 
If an object contains one or more pointers to other objects, a simple bit-wise copy may not be what you want. Copy constructors and assignment operators let you do a so-called deep copy that addresses this. For example, suppose you have the following class:
class Stuff {
    Stuff();
    ~Stuff();
    int number;
    char *string;
};
Stuff::Stuff()
  : number(0),
    string(new char[10])
{
    strcpy(string,"Stuff");
}
Stuff::~Stuff()
{
    delete []string;
}
A bit-wise copy of one Stuff object to another simply copies the pointer to the string member. If one of the objects is then deleted, the other object's string member now points to freed memory. With a deep copy, you can ensure that each instance of the Stuff object has its own copy of the string:
class Stuff {
    Stuff();
    Stuff(const Stuff &stuff);
    ~Stuff();
    int number;
    char *string;
};
Stuff::Stuff()
  : number(0),
    string(new char[10])
{
}
Stuff::Stuff(const Stuff &stuff)
  : number(stuff.number),
    string(new char[10])
{
    strcpy(string,stuff.string);
}
Stuff::~Stuff()
{
    delete []string;
}



Software Zen: delete this;
GeneralRe: Generic C++ object/structure swap Pin
Scott K4-May-03 8:42
Scott K4-May-03 8:42 
GeneralRe: Generic C++ object/structure swap Pin
Jambolo4-May-03 11:05
Jambolo4-May-03 11:05 
QuestionCan u choose a way to do this? Pin
Mahesh Perumal2-May-03 5:15
Mahesh Perumal2-May-03 5:15 
AnswerRe: Can u choose a way to do this? Pin
David Crow2-May-03 5:21
David Crow2-May-03 5:21 
GeneralRe: Can u choose a way to do this? Pin
Mahesh Perumal2-May-03 6:14
Mahesh Perumal2-May-03 6:14 
GeneralRe: Can u choose a way to do this? Pin
David Crow2-May-03 8:27
David Crow2-May-03 8:27 
GeneralRe: Can u choose a way to do this? Pin
Mahesh Perumal2-May-03 19:52
Mahesh Perumal2-May-03 19:52 
GeneralI need help with files please Pin
FARGORE2-May-03 5:09
FARGORE2-May-03 5:09 
GeneralRe: I need help with files please Pin
jhaga2-May-03 6:32
professionaljhaga2-May-03 6:32 
GeneralRe: I need help with files please Pin
Neville Franks2-May-03 7:22
Neville Franks2-May-03 7:22 
GeneralRe: I need help with files please Pin
John R. Shaw2-May-03 17:21
John R. Shaw2-May-03 17:21 
Generalsocket() programming question! Pin
peter ho2-May-03 4:07
peter ho2-May-03 4:07 
GeneralRe: socket() programming question! Pin
Joseph Dempsey2-May-03 5:03
Joseph Dempsey2-May-03 5:03 
GeneralUsing VC to do digital signal processing Pin
George22-May-03 2:50
George22-May-03 2:50 
GeneralImmediate help required for RADIO BUTTONS Pin
Anonymous2-May-03 2:27
Anonymous2-May-03 2:27 
GeneralRe: Immediate help required for RADIO BUTTONS Pin
imsniper2-May-03 2:30
imsniper2-May-03 2:30 
GeneralRe: Immediate help required for RADIO BUTTONS Pin
Michael P Butler2-May-03 3:12
Michael P Butler2-May-03 3:12 

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.