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

C / C++ / MFC

 
AnswerRe: Disk Wipe Pin
Member 862075916-Oct-13 2:11
Member 862075916-Oct-13 2:11 
AnswerRe: Disk Wipe Pin
Vaclav_16-Oct-13 14:43
Vaclav_16-Oct-13 14:43 
SuggestionRe: Disk Wipe Pin
SoMad16-Oct-13 17:17
professionalSoMad16-Oct-13 17:17 
AnswerRe: Disk Wipe Pin
Albert Holguin17-Oct-13 5:33
professionalAlbert Holguin17-Oct-13 5:33 
AnswerRe: Disk Wipe Pin
TheKingofdemon3318-Oct-13 9:14
TheKingofdemon3318-Oct-13 9:14 
QuestionPolymorphism & Assignment Op. & Copy Constructors in C++ Pin
federico.strati15-Oct-13 2:16
federico.strati15-Oct-13 2:16 
AnswerRe: Polymorphism & Assignment Op. & Copy Constructors in C++ Pin
Aescleal21-Oct-13 4:45
Aescleal21-Oct-13 4:45 
GeneralRe: Polymorphism & Assignment Op. & Copy Constructors in C++ Pin
federico.strati21-Oct-13 22:04
federico.strati21-Oct-13 22:04 
Thanks Aescleal,

all the techniques you suggest are fine, but my point was more on the discussion
of the copy ctor and assignment op. themselves: it is clear that if I make them
private, or if I just use the compiler generated ones for POD types, there will
be no worry.

By the way what do you mean exactly by "copy and swap" ? Do you mean this ? :
C++
Object& operator = (const Object& other)
{
   Object(other).swap(*this);
   return *this;
}

(How do you ensure no self assignment in this case ?, by forwarding to std::swap ?)

My point anyway was about how to do in the correct way when I've a hierarchy,
I've deep copies, I've to be able to use base class pointers or derived pointers:
i.e. in the most general case.

In this general case it seems to me that you're forced to use one of the given approaches,
and that you shall handle all cases of copy ctor and assignment ops explicitly
(derived from derived, derived from base, base from derived, base from base)
maybe just disallowing some of them.

Just to be clear, my point is the following:
C++
CBase* pbase0 = new CDerived(...);
CBase* pbase1 = new CDerived(...);

*pbase0 = *pbase1 // Will it works correctly or will it slice and I should disallow it ?


Bye
Federico

modified 22-Oct-13 4:44am.

GeneralRe: Polymorphism & Assignment Op. & Copy Constructors in C++ Pin
Aescleal21-Oct-13 23:15
Aescleal21-Oct-13 23:15 
GeneralRe: Polymorphism & Assignment Op. & Copy Constructors in C++ Pin
federico.strati22-Oct-13 0:12
federico.strati22-Oct-13 0:12 
QuestionSQLFetchScroll is failing if database column contains NULL value Pin
Ashish Ranjan Mishra14-Oct-13 21:13
Ashish Ranjan Mishra14-Oct-13 21:13 
AnswerRe: SQLFetchScroll is failing if database column contains NULL value Pin
Rajesh R Subramanian14-Oct-13 22:24
professionalRajesh R Subramanian14-Oct-13 22:24 
GeneralRe: SQLFetchScroll is failing if database column contains NULL value Pin
Ashish Ranjan Mishra14-Oct-13 23:24
Ashish Ranjan Mishra14-Oct-13 23:24 
GeneralRe: SQLFetchScroll is failing if database column contains NULL value Pin
Rajesh R Subramanian14-Oct-13 23:29
professionalRajesh R Subramanian14-Oct-13 23:29 
GeneralRe: SQLFetchScroll is failing if database column contains NULL value Pin
Rajesh R Subramanian14-Oct-13 23:34
professionalRajesh R Subramanian14-Oct-13 23:34 
GeneralRe: SQLFetchScroll is failing if database column contains NULL value Pin
Ashish Ranjan Mishra15-Oct-13 9:41
Ashish Ranjan Mishra15-Oct-13 9:41 
GeneralRe: SQLFetchScroll is failing if database column contains NULL value Pin
Rajesh R Subramanian15-Oct-13 11:30
professionalRajesh R Subramanian15-Oct-13 11:30 
QuestionPassing class pointer via socket Pin
Don Guy14-Oct-13 13:09
Don Guy14-Oct-13 13:09 
AnswerRe: Passing class pointer via socket Pin
Richard Andrew x6414-Oct-13 14:34
professionalRichard Andrew x6414-Oct-13 14:34 
GeneralRe: Passing class pointer via socket Pin
pasztorpisti14-Oct-13 21:50
pasztorpisti14-Oct-13 21:50 
AnswerRe: Passing class pointer via socket Pin
Erudite_Eric14-Oct-13 17:10
Erudite_Eric14-Oct-13 17:10 
AnswerRe: Passing class pointer via socket Pin
ExcellentOrg14-Oct-13 21:20
ExcellentOrg14-Oct-13 21:20 
AnswerRe: Passing class pointer via socket Pin
Rajesh R Subramanian14-Oct-13 22:43
professionalRajesh R Subramanian14-Oct-13 22:43 
AnswerRe: Passing class pointer via socket Pin
Albert Holguin15-Oct-13 6:39
professionalAlbert Holguin15-Oct-13 6:39 
GeneralRe: Passing class pointer via socket Pin
Don Guy15-Oct-13 6:48
Don Guy15-Oct-13 6:48 

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.