Thread: Multiplication of two objects of same class. Class should have an array of 10 intege

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    1

    Post Multiplication of two objects of same class. Class should have an array of 10 intege

    Problem Statement: Multiplication of two objects of same class
    • Write a class. Class should have an array of 10 integers as its private data member.
    Class should have
    • A default constructor which will initialize all array elements with zero.
    • Getter and setter functions
    • An operator overloading function which will overload * operator for this class.

    1. Create three objects of the same class.
    2. Must assign values to first and second objects through setter functions. You can either take input arrays from user or use hard coded values.
    3. Display the values of first and second object through getter functions.
    4. Multiply both objects and store the result of multiplication in third object.
    5. Multiplication means the 1st element of member array of object1 should be multiplied by 1st element of member array of object2. Similarly, 2nd element should be multiplied with 2nd and so on. In the end, display the result stored in third object.
    6. Your program should support the statement like a = b * c, where a, b and c are objects of the same class.

    -------------------------------------------------------------------------
    Sample output:
    Object 1 :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    Object 2 :
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1

    Multiplication of both objects :
    10
    18
    24
    28
    30
    30
    28
    24
    18
    10

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Are you offering a job here? please have the good grace to actually write some kind of 'hello, i need help with...' at the very least, just posting your study paper is plain rude.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Ya know, thanks to all the posters like this we should have a pretty good list of beginner exercizes by now.
    Hey someone's got to benefit from the fools who do nothing but post up their assignement description.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Your imaginary friend
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    76
    Since your just plain rude, I won't make any code for you, but since your asking for help that's what I'll do:

    make 2 linear arrays of 10 "blocks" with each needed number in the right place. make the two first numbers multiply each other, do the same for the other numbers


    This is the way I'd do it so you might have another idea

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array of class objects
    By te5la in forum C++ Programming
    Replies: 4
    Last Post: 07-23-2008, 05:37 PM
  2. Overloading Array Objects for use with Classes
    By ibleedart in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2007, 06:48 PM
  3. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM

Tags for this Thread