Prog - Private Members in Java/C++

Well as we all know private members of a class cannot be accessed directly by objects. We need to use member functions to access them. This is true for all cases. Or so I thought until I encountered few cases where this ain't true.

For the first, one thing has to be understood. Memory for the member variables are arranged in a sequential manner. So by performing arithmetic calculations on the address of the public variables we can get the address of the private members and hence access them.

Second. I found this when i was looking at copy constructors. A sample copy constructor would look something like this.

class sample
{
private : int i,j;
public:
sample(sample A)
{
i=A.i;
j=A.j;
}
...
...
};

Here the object A seems to access it s private members without calling any of it's own member functions(the constructor it is present is not called by that object). Now look at the following code.

class sample
{
private: int i,j;
public:
void well( )
{
sample test;
test.i = 5; //test accessing it s private members without
test.j = 10; // use of any objects
}
...
...
}

So the point is an object created inside a member function of the same class can access the private members directly. Note that the member function should be from the same class. For eg if the well( ) func had been in another class it would show error that object trying to access private members.

There is of course another, much simpler way of accessing these private members. By simply changing the "private" keyword to "public" keyword :)

Note : The above logics are applicable in both C++ and Java.

Revelations out of Sickness To A Friend

If you are wondering what exactly i mean just refer this :)


- If it is starting of a semester, staff will be see you as a calm student in class.

- Sleeping is just not fun anymore.

- You will find yourself writing notes simply due to boredom.

- Going to the canteen alone :(

- Break and lunch time turns from "free time" to "class-like time".

- Lying to your parents about seeing him. They wont allow it because you would get the sickness from him.

- Sudden prayers to God(?)

- More than usual amount of Fifa :)

- Sudden increase in messages from him/her.

- No need to worry about cricket score update.

- Sudden increase of people in your class.

- Telling your friend size of the needle does matter.

-Lying to him that "The Machinist" was a good movie.

-And after he returns, more place in the bench for me to sit :P

10 Things Parents Must Know About Their Younger Child

Being a younger brother, I know how things go with parents and the "big" brother. But whatever happens most parents don't seem to get few things like...

-> We are not a smaller version of our brother.

-> Big brothers are physically stronger than us. So we re not stupid enough to have started a fight with him, whatever he says.

-> We do not appreciate being told how good our big brother was.

-> We and they do not face the same competition. Ours is more tougher.

-> When we do something, like telling a lie, we are not doing it exactly like our brother. We are doing it like a billion other people.

->We do not exactly enjoy when someone says "You will maybe one day become like your brother".

-> Just because they are bit older than us does not mean we have to take his share of the beatings.

-> It is not technically possible for me to score more marks in 10th than he did in 12th. I write for 1100, he writes for 1200.

-> We are not responsible for his low marks in his Board exam.

-> It is not my fault I am not as tall as my brother. It is not, in most cases, biologically possible.

The SUPERstitious Beliefs

Well it's a Friday night and I am sitting in the front of my house just looking at passing by vehicles. Then I notice something weird. The shopkeeper near my house sets fire to something outside his shop. When I asked my Grandmother she explains that it improves his buisness. Hmmm.
We have so many superstitious beliefs that sound stupid but are very very true. Don't believe me? Here are the proofs for some :)

First. The burning before the shop. Well this is a very good tactic if any other shopkeeper near your house has any breathing problems. If you continue to burn stuff that guy s gonna get irritated and vacate the place. Another good thing is if you add some nice ingredients into that fire the horrible odor it emits can effectively keep away thieves at night. Last and finally watching something burn gives some people personal satisfaction.

Second. Remember when you bought your first new bike and your parents made you ride it over a lemon first? Trust me it has it's uses. If your bike skids and falls at that time you will remember that the next time you drive near a market. More importantly lemons are good Antibacterials. So you are cleaning up the floor! And let's face it, we all like the smell of fresh lemon juice.

Third. The concept of "ave kannu vachita". Now if we think properly when do we say "ave onna pathu kannu vachita" huh? When initially we have been acting like a jerk and showing off stuff when we should have kept our mouths shut. So basically when something bad happens the next time and someone says this, you are gonna become the most modest person ever right?

Fourth. Going to the temple at the wake of dawn and going round some God for 9 times(someone said the no. of times must be a multiple of 3). It s the perfect solution to get people out of their beds early and the "walking around" gives us the physical exercise we all so need and so not care about. The idea of keeping to multiples of 9 simply helps you get better at counting.

Fifth. The idea of something wrong going to happen when a cat walks across your path. Now if a cat does cross your path you are gonna be extra careful right? That s something no amount of advice can achieve. Also we marry donkeys to get rain right? Well that s done during the dry summer season when even the animals are all out of food. In the name of marriage we are doing the job of the Blue Cross.

There are many such explanations for all the so-called "Superstitious" beliefs. So next time you see someone doing anything like this, think before you speak.

I am not saying these superstitions are right. I am merely saying that behind these seemingly crazy stuffs there might be a sensible person trying to reach out to a not-so-sensible crowd.

THE Duel

Ever since my childhood i have wondered about God and science and the conflicts between them. This poem is based on this ever debated topic.

"Only God can save you", said my heart,
My brain to that replied "that's rubbish";
Between these two voices was I caught,
For I did not know which was gibberish.

My heart said that God really existed,
A proof my brain immediately demanded;
"Look around you, the things He has created!"
"Evolution and time are the true creator".


"If God did exist, tell me why,
Why are there thieves and killers?
And why so many innocent die
When God is indeed a true lover?"

"It is a test that we all must take,
For only to live is our duty and
Leave the rest to Him for our sake
As He created this life and this sand"

Thus raged the battle within me forever,
And I knew not which one to trust,
For both were filled with power;
I will know only when I go to dust.

Sai

The Dying Man

This is something i wrote some time back when i had left my mind to
wander...

The stars on the sky he was counting,
Lying on the river bed of a river red;
In his heart he knew he was dying,
As a bright darkness engulfed his eyes.

He had often wondered what death brings,
Now for the moment of truthness come,
Waited he with broken heart,dead brain
Saw scenes,vaguely familiar were some.

As doom approached,a voice spoke in him
"Chasing ever a dream i lived my life,
Found it not for i knew it not,that
Life is folly,life is full of sorrows"

"I was born unknown, now die unknown
Just like a worm,though I in the end
Was brought down by treachery,like many;
Betrayal-the gift for all acts by me"

His heart was delirious,his mind clear
"We live everyday only to die one day,
One day we die for others to live everyday
Thus goes on the endless circle of life"

"We try to answer questions before we die,
And find the answers only after we die"
Thus realizing,he forgave and forgot all
With truth realized,he smiled...

Sai

The Potter - Frodo Face-Off

Harry Potter the wizard. Frodo the ring bearer. What if the characters from Potter and LOTR (books that i greatly admire) face each other in a duel for honour? First we discuss about the teams.

The Potter Team :-
*Dumbeldore - The Greatest Wizard Of Our Time (Captain)
*Harry Potter - The Boy Who Lives
*Voldemort - The Dark Lord
*Ronald Weasley - Trusted Friend
*Severus Snape - The Real TeamMan

The Tolkien Team :-
*Gandalf (Captain) - The White Wizard
*Frodo Baggins - The Ring Bearer
*Sauron - The Maia
*Samwise Gamgee - Gardener At Bag End
*Aragorn - Heir Of Isiuldur

Round 1 :- Samwise Gamgee vs Ronald Weasley

Sam has no weapon but is brave. Ron has the wand but is a bit shaky. Sam looks at the curious object at Ron's hands. Ron seizes the moment. "Obliviate". Wand broken. Ron forgets everything. Sam now jumps on Ron an strangles him. Ron does not resist. Sam shows pity and stops the fight. Suddenly Sam freezes and falls down. A beaming Hermoine waves at Ron from the crowd.
One - Nill to The Potter's

Round 2 :- Harry Potter vs Frodo Baggins

Harry is ready as ever. Frodo is fiddling with his pocket.Harry considers what spell to use when suddenly Frodo disappears(He uses the One Ring to do this). Harry starts shooting spells randomly. Frodo sneaks slowly towards him. Out of sheer luck one of the spells hits Frodo square on the chest and he immediately freezes. Harry removes the Ring.
Two - Nil to The Potter's

Round 3:-Snape vs Aragorn

Sensing that Frodo is in danger Aragorn jumps onto the stage. Snape immediately appears to protect Harry. Snape looks straight into Aragorn s eyes. A little child running. A tall man with a beautiful women. A man standing crest fallen before the statue of Isildur. Aragorn rises from the dream. He summons the Army Of The Dead. Snape s spells are useless against them. Aragorn with one swift stroke breaks Snape s wand into two.
Two - One to The Potter's

Round 4:-Sauron vs Voldemort

Two great Dark Lords. Feared by all. Sauron with his ring believes he is invincible. Voldemort knows he is immortal with all his Horcruxes. Just as the battle is about to start the Nine Nazguls appear. Voldemort is hit with an epiphany. He knows the horcruxes are gone. Sauron, with the One Ring and his mace advances. Voldemort desperately uses defensive spells. Sauron uses ancient magic to summon the Balrog. Voldemort is clueless. One slash from the fire-sword of Balrog and game over.
Two all now.

Round 5:-Dumbeldore vs Gandalf

Dumbeldore looks at Gandaly the Grey. Before anyone can even move Dumbeldore draws his wand and shoots a spell at Gandalf. Gandalf falls. Everyone is stunned to realize the battle is over. Just as the Potter s were to be declared as the winner Gandalf the White appears. Gandalf says "Now I come, at the turn of the tide". An intense battle between Dumbeldore and Gandalf ensues. As both men become weary they realise the amount of damage done by them. This was not what they both desired.Both stop fighting. They look into each other's eyes.

As they say the rest is history.