Jump to content


  • Content count

  • Joined

  • Last visited

Everything posted by SunnyPalSingh

  1. Read This http://cplus.about.com/od/beginnerctutoria1/l/aa042902d.htm
  2. SunnyPalSingh

    interview data structures

    Read the FAQ's in this forum.
  3. SunnyPalSingh

    c doubt

  4. SunnyPalSingh

    difficult question indeed

    illegal is a very strong word. I would rather say it's conversion between incompatible types and I never denied that. I said it's a valid "C" code and I still say that. Again, I never said there is a problem with printf statement. I simply explained the OP the working of the program. Hope you get it.
  5. SunnyPalSingh

    can any1 write the folowing programs in C

    We'll really be interested to help you if you show your efforts.
  6. Function Pointers are pointers, i.e. variables, which point to the address of a function. For example statement like this void (*ptrtoFunction)(void);creates pointer to a function which takes no parameters and returns no value. Another example int (*ptrtoFunction)(float, char, char);creates pointer to a function which take three parameters of type float, char, char and returns int value. Sample code #include<stdio.h>void function(void); //function declerationint main(void){ void (*ptrtofunction)(void); //declaring pointer to a function which does not return anything and take no parameters ptrtofunction=function; //giving address of function to ptrtofunction ptrtofunction(); //calling of function through function pointer return 0; }void function(void){ printf("Function called through function pointer\n");}Function Pointers provide some extremely interesting, efficient and elegant programming techniques. Some of the places I remember they can be used are:[*]You can use them to replace switch/if-statements, to realize your own late-binding. [*]You can use them to implement callbacks. I hope this short description will get you started. If you have any doubts then you can post back.
  7. SunnyPalSingh

    Reputation System

    Hi I am regular visitor of many forums. Most of them have a feature of Reputation System.People add to the reputation of poster whose post is useful. I really like that concept. This will attract more people to start using forums. So, Is it possible to have such a thing on this Chetanasforum. Thank You
  8. SunnyPalSingh

    c/c++ projects very urgent

    What kinda project do you need???
  9. SunnyPalSingh


    >What is the use of pure virtual function? Pure Virtual Function A member function declaration that turns a normal class into an abstract class. You normally only implement those functions in a derived class. Sample Code class Shape { public: virtual void draw() const = 0; // = 0 means it is "pure virtual" ... };
  10. SunnyPalSingh


    >What is the use of Abstract base class?Abstract base class is a class which can not be instantiated. This class acts as base for other classes.
  11. SunnyPalSingh

    copy constructors in c++

    Copy Constructors are constructors which are used to construct and initialise an object from already constructed object.
  12. Hi Chetana MamI am unable to find any placement paper of Impetus. Can you tell me about the pattern.Please help. It's really urgent.Thank You.
  13. SunnyPalSingh

    this keyword

    this is a reference to the current object — the object whose method or constructor is being called. A constructor is a special member function which is executed when an object is instantiated from a class . super has many functions >Invoke the superclass constructor >Invoke the noarg superclass constructor >Invoke a parameterized superclass constructor >Invoke the noarg superclass constructor by default
  14. SunnyPalSingh

    puzzle for infy

    Someone Plz Explain This.
  15. SunnyPalSingh

    C expressions..

    Undefined Behaviour
  16. SunnyPalSingh


    Can someone answer these please...
  17. SunnyPalSingh

    Aptitude questions

    Result is undefined according to standard C.
  18. SunnyPalSingh

    difficult question indeed

    It's a perfectly valid "C" code. Output of printf("%c",*ptr); will be some character(varying from machine to machine) whose ascii value is 2. Output of printf("%d",*ptr); will be 2 always. Output of printf("%d",*((int*)(ptr-1))); Will be 556.
  19. Why do you think compiler will not do that for you. Compiler might be internally optimising things for you. There may be a possibilty(when cases are sparsely distributed) that switch may be internally converted to if-else. So, we shouldn't be worried about such things.
  20. SunnyPalSingh

    how this code works?

    It's sequence point not segment point.
  21. Even though there is little impact for fundamental types, since we programmers are human, you will produce programming habits. And those habits will carry over to when we deal with classes instead, for example iterators.There was an informal study done (sorry I forgot the source) on a number of people who say "I only use post-incrementing/decrementing for fundamental types." The results showed that they very frequently used the post-increment/decrementing operators for iterators and other classes leading to a great amount of wasted CPU cycles in the end code.
  22. In Short- Undefined Behaviour
  23. SunnyPalSingh

    What is Extern variable ?

    The extern keyword declares a variable or function and specifies that it has external linkage (its name is visible from files other than the one in which it's defined)