Document by 409

Embed Size (px)

Citation preview

  • 8/9/2019 Document by 409

    1/3

    Operator Overloading

    1. Write a C++ program to create a class called COMPLEX and implement the addition of two

    complex nm!ers !" overloading +

    #. Write a C++ program to create a class $%&'() and implement the following operations.

    *ispla" the reslts after ever" operation !" overloading the operator ,%o compare two strings-+,to

    concatenate two strings

    i- $%&'() s1/C0*C/

    ii- $%&'() s#/Electronics Cit"/

    ,iii- $%&'() s2s1+s#

    2. Overload + operator to add two 3ox o!4ects. Create a class 3ox with mem!er fnctions

    get5olmesetlengthset!readthsetheight dd l!h of two !ox o!4ects and find the volme of

    reslting !ox o!4ect.

    6. Write a C++ program to create a class called *%E. ccept two valid dates in the from of

    dd7mm7"""". 'mplement the following operation !" overloading the operator + 8 0.

    i- no9of9da"sd10 d# where d1 and d# are *%E o!4ects d1:d# no9of9da"s is an integer.

    ii- d#d1+no9of9da"s where d1 is *%E o!4ect and no9of9da"s is an integer.

    ;. Write a C++ program to create a class M%&'X sing two dimensional arra" of integers.

    'mplement the following operations !" overloading the operator which chec

  • 8/9/2019 Document by 409

    2/3

    %emplates

    1. Create a template class to store two nm!ers and inside the template class define a template fnctionto find maximm of stored nm!ers.Write a main,- program that stores two integer and displa" the

    maximm of twostore two do!le vales and displa" their maximm.

    #. Create a fnction called amax,- that retrns the vale of the largest element in an arra". %he

    argments to the fnction shold !e the address of the arra" and its si>e. Ma

  • 8/9/2019 Document by 409

    3/3

    with same e a vector with vales 1 2 D H I .?sing the !inar"9search algorithm search whether vale2; is present in the vector.

    11. 'nitiali>e an arra" with 1A elements K1..1A ?sing accmlate fnction show that the ;+A+1+..1A

    BA and 1A1#26#6A1#. ta!le gives a list of car models and the nm!er of nits sold in each t"pe in a specified

    period.Write a program to store this ta!le in a sita!le containerand to displa" interactivel" the total

    vale of a particlar model soldgiven the nit cost of the model.12. Write a program that accepts a shopping list of five items from the