Tuesday, December 3, 2013

How would a vim guru type this c++ snippet?

#include <string>

class TCTest
{
public:

void f();

private:

float mTemperature;

unsigned char mType;

double mDistanceFromCenter;

long long int mId;

std::string mName;
};

#include <string>

class TCTest
{
public:

TCTest();

TCTest(const TCTest& Other);

TCTest& operator=(const TCTest& Rhs);

void f();

private:

float mTemperature;

unsigned char mType;

double mDistanceFromCenter;

long long int mId;

std::string mName;
};

#include "test1.h"

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void TCTest::f()
{
mType = 0;
}

#include "test2.h"

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
TCTest::TCTest()
: mTemperature(0),
mType(0),
mDistanceFromCenter(0),
mId(0),
mName(0)
{
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
TCTest::TCTest(const TCTest& Other)
: mTemperature(Other.mTemperature),
mType(Other.mType),
mDistanceFromCenter(Other.mDistanceFromCenter),
mId(Other.mId),
mName(Other.mName)
{
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
TCTest& TCTest::operator=(const TCTest& Rhs)
{
if (this != &Rhs)
{
mTemperature = Rhs.mTemperature;

mType = Rhs.mType;

mDistanceFromCenter = Rhs.mDistanceFromCenter;

mId = Rhs.mId;

mName = Rhs.mName;
}

return *this;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void TCTest::f()
{
mType = 0;
}

Hello,

I wish I worked with a vim guru because I would devote a day to just watching him work. I have tried to find "vim guru" videos on youtube but that hasn't really panned out. So instead I'll turn to the group.

In the attached files, I start with a class TCTest and I add a default constructor, a copy constructor, and an assignment operator.

Regarding the change from test1.cpp -> test2.cpp, will you please do one of the following:

a) come to my office and change test1.cpp into test2.cpp so I can see how you do it.

b) record yourself changing test1.cpp -> test2.cpp and send me the video

c) tell me the characters you would type to change test1.cpp ->test2.cpp

d) give me some buzzwords and thoughts about how you would change test1.cpp -> test2.cpp

Bonus points if your approach is O(1) with respect to the number of members in the class.

Thank you!

Chris

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: