Answered Questions

  • TCS C/C++ Questions

    1. Difference between "C structure" and "C++ structure".2. Diffrence between a "assignment operator" and a "copy constructor"3. What is the difference between "overloading" and "overridding"?4. Explain the need for "Virtual Destructor".5. Can we have "Virtual Constructors"?6. What are the different types of polymorphism?7. What are Virtual Functions? How to implement virtual functions in "C"8. What...

    Star Read Best Answer

    Editorial / Best Answer

    Answered by: Rajini

    • Feb 19th, 2007


    Q. Difference between "C structure" and "C++ structure".
    Ans:- C structure cannot have member functions but C++ structure can have. Also in a C structure by default all data members of structure are public and access cannot be changed by specifying the private or protected keywords but in C++ eventhough by default members are public we may change the access using the keywords private and protected.
    Q. What is the difference between "overloading" and "overridding"?
    ans:- Overloading is a process of having the same function name but different no of arguments or types of arguments within the same class but overriding means redefining a baseclass functions definition in the subclass.
    Q. Explain the need for "Virtual Destructor".
    Ans:=Virtual destructor ensures destruction of subclass and base class objects in proper order.
    Q. What are the different types of polymorphism?
    Ans:-Overloading and overriding.
    Q. What are the different types of Storage classes?
    ans:-Auto,Register,static and extern
    Q. What is the difference between "calloc" and "malloc"?
    Ans:- calloc and malloc are used for dynamic memory allocation. Calloc initializes the memory locations to zero by default but malloc memory contains garbage values.
    Difference between "printf" and "sprintf".
    printf will write to the console. sprintf will write to the buffer

    suneel kumar alld

    • Apr 2nd, 2016

    Loop - Loop is a block of code that execute numbers of time until expression or statement return zero (0)

    Shreya

    • Feb 3rd, 2016

    Namespace : It is a declarative region that provides scope to the identifiers inside it.