+ Reply to Thread
Results 1 to 3 of 3

Thread: C++ Contest-3

  1. #1
    Moderator
    Join Date
    Feb 2006
    Posts
    1,419
    Rep Power
    25
    Answer the following



    1. What is the difference between an ARRAY and a LIST?
    2. What is faster : access the element in an ARRAY or in a LIST?
    3. Define a constructor - what it is and how it might be called (2 methods).
    4. Describe PRIVATE, PROTECTED and PUBLIC – the differences and give examples.



    \"Winners don\'t do different things.They do things Differently\"

  2. #2
    Member
    Join Date
    Apr 2006
    Location
    India
    Posts
    62
    Rep Power
    8
    1. Difference between an array and a list:

    Array is collection of homogenious elements.

    List is collection of hetrogenious elements.


    For array memory is allocated is static and continuous.

    For list memory is allocated is dynamic and random.


    Array: user need not to keep in track of next memory location.

    List: user has to keep in track of next memory location where memory is allocated.


    2. what is faster:


    it's an array bcz it is continuous.


    3. Define a constructor..........


    Constructor is a member function of the class, with the name of the function being the same as the class name. It also specified how the object should be initialized.


    Ways of calling constructor:


    1. Implicitly : automatically by compiler when object is initialized.


    2. Explicitly :calling the constructors explicitly is possible, but it makes the code unverifiable.



    4. Describe private , protected and public..............


    These keywords introduced in c++ to set the boundaries instructure or class. These access specifiers are used onlyin a class or structure declaration. Whenever you use an access specifier, it must be followed by colon.


    Anyone can access the data members or functions that are declared in public mode.


    No one can access the data members or functions that are declare in private mode except you, the creater of the type.


    protected acts like private , with one exception that the next child also can access the protected data.

  3. #3
    Senior Member
    Join Date
    Mar 2006
    Posts
    607
    Rep Power
    16


    HI,


    4.Private-Only member of that class can access.


    Protected-The members of that class and next to that can access.


    Public-All the calss members can access.
    \"A GREAT PLEASURE IN LIFE IS DOING WHAT PEOPLE SAY YOU CANNOT DO\".

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Content Relevant URLs by vBSEO 3.5.1 PL1