Thursday, July 22, 2010

C++ Array vs Object - Pass by value

You can not pass an array by "pass by value", whereas objects can be passed by value. Here is a snippet:

You can pass an array to a function in only following manner:
int arr[2] = {0,1};
void s(int arr[]){ //This statement is equivalent to: void s(int *arr)
arr[0]=2;
}

s(arr); // This passes array pointer by value and hence the complete is passed by reference. Meaning to say function s will operate on real array and not on a "copied" array of the one passed in argument.


You can pass an object to a function in two ways:
void s(Obj* o) // this statement is equivalent to: void s(Obj & o). Pass by reference
void s(Obj o) // Pass by value. The actual ojbect passed as parameter when invoking the function, gets copied and function acts on copied object and not on actual object

Wednesday, July 21, 2010

C++: Char vs String initialization

#include "iostream"                           // a PREPROCESSOR directive 
using namespace std;
int main()                                    // function header 
{                                             // start of function body 
using namespace std;                      // make definitions visible 
char * t1 = new char;
*t1 = 'a';
cout<< "Case 1: " << t1 << "\n";          //Output: a.    Valid output

char * t2;
//*t2 = 'a';                             //Can also lead to bus error. Incase it is out of memory assigned to t2
//cout<< "Case 2: " << t2 << "\n";       //Output: a???.   Garbled output, since you are trying to store 'a' in neverland

//char * t3;
//t3 = 'a';                              // Compile error: myfirst.cpp:15: error: invalid conversion from 'char' to 'char*'

//char * t4;
//* t4 = "a";                            // Compile error: myfirst.cpp:18: error: invalid conversion from 'const char*' to 'char'
// "a" is treated as string. 'a' is a character

char * t5;
t5 = "a";
cout<< "Case 5: " << t5 << "\n";         //Output: a.     Valid Output, understand that here "a" is a string and that get space assigned in memory. On the other hand, 'a' does not get stored in memory when getting assigned to pointer. Also "a" is of type const char *, where 'a' is of type const char

int * fellow;
*fellow = 123;                           //Garbled output, bus error.
fellow = (int *)123;                     //fellow points to some location in memory and will result in bus error while we are accessing it.
return 0;                                // terminate main() 
}   

Monday, July 19, 2010

http://www.ted.com/index.php/talks/lang/eng/jill_bolte_taylor_s_powerful_stroke_of_insight.html

Jill's speech was so impressive. Setting up the mind to share Her experience during a severe hemorrhage is great..the feeling of 'nirvana' is the most inspiring though I am little confused about the experience during such trauma.
Buddha and few other persons are known to experience the rare NIRVANA during their lifetime..bt here,JBT experienced that rare happening during hemorrhage..unbelievable and inspiring.

http://www.ted.com/index.php/talks/lang/eng/jill_bolte_taylor_s_powerful_stroke_of_insight.html

Saturday, July 17, 2010

How to talk to VC (Dos and Donts)

Some sample questions a mentor can ask:
  • If I give you 1 crore how will u invest that in a day
    • Best ans: 30 lakh for myself and my family future and comforts, rest 70 lakh for business. May be I will hire 4-5 best brains to work for me, etc etc. Or how u plan to grow your current business
    • Mentor wants to judge how much are you concerned for your personal comfort, do u have a vision to invest money in your business
  • Most exciting thing you did in college or life
    • It can be academics but also something non academic. How passionate you are to achieve what you want. Something you really wanted to do and you went out of way, went crazy to do it
    • Winning some trophy, Getting gf, some adv trek
  • How ur friends describe you?
    • Friends can judge you best. Some answers can be:
      • visionary, Reliable, strong temperament, enthusiastic, etc
  • Family background
    • Mentor wants to figure out if you have future personal commitment. Most of entrepreneurs drop because of family reasons
  • Why do you want to open a startup - THIS IS IMPORTANT
    • Don’t say lame reasons here. It will haunt you back :)
    • Something like: you know you company earns 50 lakh from you and gives you only 10 lakh of it. You think you deserve better with you skill set and ideas and want to make a place for yourself. Please note the assumption that if your company make a profit of 100 crores with 100 employees, it entitles you to get 1 crore, IS FLAWED. Company doesn’t make 100 crores only from employees but also from the idea, its brand value, etc. But then you also have a great idea WHICH ADDS VALUE to current market and hence you want to follow up your dreams.