என்று முடியும் இந்த வாழ்க்கை?
Friday, May 15, 2026
Wednesday, May 6, 2026
வருகிறேன்!!!
எத்தனை தோழர்கள்
இருந்தாலும்
என் மனம் விட்டு பேச
ஆழ் மனது ஆசைகைளை
ஒலிவின்றி கூற
ஒரு தோழியிடமே முடியும்!
கல்லூரி காலத்தில்
விட்டு சென்ற ஒருத்திக்காக
நான் இழந்தவை ஏராளம்!
மீண்டும் அப்படி ஒரு இழப்பு
வேண்டாமென்று நான்
தேர்தெடுத்தவள் என் மனைவி!
நான் புதியவனாக இருந்தபொழுது
என் ஆசைகளே அவளது என்றாள்!
இன்றோ எல்லாம் இழந்த
பழைய காதிதமாய் நான்!
என் எண்ணங்கள் என்னவென்று
கூட அறிய ஆசைப்படாத அவள்!
என்ன ஆனாலும் மீண்டு வருவேன்
என்ற நான் இனி நான் ஏன்
வாழ வேண்டும் என்ற நிலையில்!
மனைவியாக அவள் வென்று விட்டாள்!
என் உயிரை கொன்று
தோற்றுவிட்ட நான்!
என் மகள் ஒன்றை தவிர
நான் வாழ எவ்வித
பிடிப்பும் இல்லை.
நான் இல்லா வாழ்க்கையை
அவள் பழகிவிடுவாள்
என்ற நம்பிக்கையில்
மரணத்தை நோக்கி நான்!!!!
இருண்ட இவ்வுலகம்
தொலைவில் அலைக்கும் வெளிச்சம்!!!!
Friday, May 24, 2024
உளறல்!
Thursday, December 28, 2023
உண்மையின் வலி!!!!
Tuesday, December 26, 2023
கனவிலும் நீ...
Saturday, April 22, 2023
மழையும் கண்ணீரும்!!!
Friday, March 10, 2023
மரணத்திடமிருந்து ஒரு அழைப்பு!
Wednesday, February 8, 2023
உயிரின்றி நான்!!!!
Wednesday, January 25, 2023
Friday, September 2, 2022
Wednesday, July 13, 2022
கடவுளே காப்பாற்று
ஏன்?
சரியா?
யார் தவறு?
இருபது வருடங்களின் ஏக்கம். இருவது நொடிகளில் அழித்து விட்டாள்.
என்ன செய்வேன்? எவ்வாறு என்னை மாற்றிக் கொள்வேன்?
மாற்றிக் கொள்ள முடியுமா? கடவுளே...
நான் கூட தவறு செய்ய ஆசைப்படுகிறேன் எனக் கூறி உண்மையாய் இருந்து விட்டேன். ஆனால் அவள்? என்னை புரிந்து கொண்டாள் என நான் நம்பிய அவள்? 😭😭😭😭
ஆண்டவா என்னை காப்பாற்று.. காப்பாற்று...
Monday, April 1, 2019
ஏனோ மாட்டேன் யென்கிறது மனது .
அறிவுக்கெட்டவில்லை மனதின் வலி .
வாய்விட்டு அழுதேன் வலி குறைந்தது.
தொலைத்து விட்ட நம்பிக்கையை
யெவ்வாறு மீட்டெடுப்பேன்?
மஞ்சம் என்னை வெறுக்கிறது.
நான் இரவை வெறுக்கிறேன்.
கண்களோடு தலையணையும் ஈரம்,
இவை வெறும் புலம்பல்களே!
பொருளை தேடாதே!!
ஏனனில் நான் நானாக இல்லை!!!.
நீ யென் அருகிலிருந்தும்
யேனோ தனிமையின் துயரம் .
Sunday, March 24, 2019
Saturday, March 23, 2019
Monday, August 13, 2018
The Rule of Three
Introduction
class person
{
std::string name;
int age;
public:
person(const std::string& name, int age) : name(name), age(age)
{
}
};
int main()
{
person a("Bjarne Stroustrup", 60);
person b(a); // What happens here?
b = a; // And here?
}
name(name), age(age) part, this is called a member initializer list.)Special member functions
person object? The main function shows two distinct copying scenarios. The initialization person b(a); is performed by the copy constructor. Its job is to construct a fresh object based on the state of an existing object. The assignment b = a is performed by the copy assignment operator. Its job is generally a little more complicated, because the target object is already in some valid state that needs to be dealt with.The [...] copy constructor and copy assignment operator, [...] and destructor are special member functions. [ Note: The implementation will implicitly declare these member functions for some class types when the program does not explicitly declare them. The implementation will implicitly define them if they are used. [...] end note ] [n3126.pdf section 12 §1]
The implicitly-defined copy constructor for a non-union class X performs a memberwise copy of its subobjects. [n3126.pdf section 12.8 §16]The implicitly-defined copy assignment operator for a non-union class X performs memberwise copy assignment of its subobjects. [n3126.pdf section 12.8 §30]
Implicit definitions
person look like this:// 1. copy constructor
person(const person& that) : name(that.name), age(that.age)
{
}
// 2. copy assignment operator
person& operator=(const person& that)
{
name = that.name;
age = that.age;
return *this;
}
// 3. destructor
~person()
{
}
name and age are copied, so we get a self-contained, independent person object. The implicitly-defined destructor is always empty. This is also fine in this case since we did not acquire any resources in the constructor. The members' destructors are implicitly called after the person destructor is finished:After executing the body of the destructor and destroying any automatic objects allocated within the body, a destructor for class X calls the destructors for X's direct [...] members [n3126.pdf 12.4 §6]
Managing resources
std::string, and programmers were in love with pointers. The person class might have looked like this:class person
{
char* name;
int age;
public:
// the constructor acquires a resource:
// in this case, dynamic memory obtained via new[]
person(const char* the_name, int the_age)
{
name = new char[strlen(the_name) + 1];
strcpy(name, the_name);
age = the_age;
}
// the destructor must release this resource via delete[]
~person()
{
delete[] name;
}
};
name member merely copies a pointer, not the character array it points to! This has several unpleasant effects:- Changes via
acan be observed viab. - Once
bis destroyed,a.nameis a dangling pointer. - If
ais destroyed, deleting the dangling pointer yields undefined behavior. - Since the assignment does not take into account what
namepointed to before the assignment, sooner or later you will get memory leaks all over the place.
Explicit definitions
// 1. copy constructor
person(const person& that)
{
name = new char[strlen(that.name) + 1];
strcpy(name, that.name);
age = that.age;
}
// 2. copy assignment operator
person& operator=(const person& that)
{
if (this != &that)
{
delete[] name;
// This is a dangerous point in the flow of execution!
// We have temporarily invalidated the class invariants,
// and the next statement might throw an exception,
// leaving the object in an invalid state :(
name = new char[strlen(that.name) + 1];
strcpy(name, that.name);
age = that.age;
}
return *this;
}
name to prevent memory leaks. Also, we have to protect against self-assignment of the form x = x. Without that check, delete[] name would delete the array containing the sourcestring, because when you write x = x, both this->name and that.name contain the same pointer.Exception safety
new char[...] throws an exception due to memory exhaustion. One possible solution is to introduce a local variable and reorder the statements:// 2. copy assignment operator
person& operator=(const person& that)
{
char* local_name = new char[strlen(that.name) + 1];
// If the above statement throws,
// the object is still in the same state as before.
// None of the following statements will throw an exception :)
strcpy(local_name, that.name);
delete[] name;
name = local_name;
age = that.age;
return *this;
}
Noncopyable resources
private without giving a definition:private:
person(const person& that);
person& operator=(const person& that);
boost::noncopyable or declare them as deleted (C++0x):person(const person& that) = delete;
person& operator=(const person& that) = delete;
The rule of three
If you need to explicitly declare either the destructor, copy constructor or copy assignment operator yourself, you probably need to explicitly declare all three of them.
Advice
std::string already does it for you. Just compare the simple code using a std::string member to the convoluted and error-prone alternative using a char* and you should be convinced. As long as you stay away from raw pointer members, the rule of three is unlikely to concern your own code.