Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Create / maintain rule of 5
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

stoodsmj
New Member

Australia
4 Posts

Posted - Nov 16 2016 :  4:01:13 PM  Show Profile  Reply with Quote
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.

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Nov 17 2016 :  1:08:48 PM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page

stoodsmj
New Member

Australia
4 Posts

Posted - Nov 24 2016 :  05:36:59 AM  Show Profile  Reply with Quote
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
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Nov 25 2016 :  11:29:01 AM  Show Profile  Reply with Quote
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
Go to Top of Page

stoodsmj
New Member

Australia
4 Posts

Posted - Nov 25 2016 :  5:14:33 PM  Show Profile  Reply with Quote
Sweet - that would be very handy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000