T O P I C R E V I E W |
stoodsmj |
Posted - Nov 16 2016 : 4:01:13 PM Be pretty cool to have VAssistX create and maintain these functions. They happen a lot, and to even have the boilerplate declarations and implementations would be extremely helpful. |
4 L A T E S T R E P L I E S (Newest First) |
stoodsmj |
Posted - Nov 25 2016 : 5:14:33 PM Sweet - that would be very handy. |
accord |
Posted - Nov 25 2016 : 11:29:01 AM What I can imagine Visual Assist doing for you is creating and updating some of these methods for you, most notably the copy constructor and such. We're considering to have this as a refactoring command:
case=3945 |
stoodsmj |
Posted - Nov 24 2016 : 05:36:59 AM Rule of 3 / 5 is explained here http://en.cppreference.com/w/cpp/language/rule_of_three
A sample code is:-
Declaration:-
class CSample { public: //ctor CSample();
//copy ctor CSample(const CSample & theOther);
//assignment CSample & operator=(const CSample & theOther);
//move ctor CSample(CSample && theOther);
//move assignment CSample & operator=(CSample && theOther);
//dtor /* optional virtual*/ ~CSample();
protected: int m_nInt;
CSample * m_pChild = nullptr; };
Implementation:- #include "stdafx.h" #include "SampleClass.h"
CSample::CSample() { }
CSample::CSample(const CSample & theOther) { m_nInt = theOther.m_nInt; m_pChild = new CSample(*theOther.m_pChild); }
CSample & CSample::operator=(const CSample & theOther) { // TODO: insert return statement here if (this == &theOther) { return *this; }
m_nInt = theOther.m_nInt;
delete m_pChild; m_pChild = new CSample(*theOther.m_pChild);
return *this; }
CSample::CSample(CSample && theOther) {
m_nInt = theOther.m_nInt;
m_pChild = theOther.m_pChild;
theOther.m_pChild = nullptr; }
CSample & CSample::operator=(CSample && theOther) { // TODO: insert return statement here if (this == &theOther) { return *this; }
m_nInt = theOther.m_nInt;
delete m_pChild; m_pChild = theOther.m_pChild; theOther.m_pChild = nullptr;
return *this; }
CSample::~CSample() { delete m_pChild; }
Cheers,
Mike
|
feline |
Posted - Nov 17 2016 : 1:08:48 PM Can you explain what you are talking about here? I don't recognise this term off hand. There are lots of different schools of thought for programming, and how code should be structured after all. |