Thread: can anyone explain this question for me?

  1. #1
    Registered User
    Join Date
    Oct 2008

    can anyone explain this question for me?

    hi i got my second assigment here for oop in c++.
    but i don't understand clearly.
    can anyone explain it to me?


    Objective: 1.Learn how to write class which uses dynamic memory allocation

    2. Learn how to invoke member function/send message to object

    There are several ways to represent whole numbers in digital computer which are equivalent to each other. Namely,

    a. Signed

    b. Unsigned

    c. Two complement.

    Numbers are represented as binary in computer system. In this assignment you will write program about how computer treat numbers that you see as decimal integers. Particularly, we are considering unsigned representation/format.

    You have to create a class named UINT that represents (unsigned) binary representation of integer. For example, the (unsigned) binary representation of 35 is 00100011 (8-bit word) or 00000000 00100011 (16-bit word).

    It has int pointer type data member to store the binary digits that represent an integer number and int data member to store the length of the array of int pointer.

    A constructor with int argument as initial value to the UINT object. For example, you can declare

    UINT t(456);

    A member function int toint() that converts the binary into int.

    A member function UINT add(UINT) that adds to UINT objects(note: be careful of overflow error).

    A member function void print1() that prints the binary representation of an integer number (the content of the pointer). It prints 00100011 instead of 35.

    A member function void print2() that prints the decimal value of the variable. It prints 35 instead of 00100011.

    A destructor that delete the pointer when a UINT object exits its scope.


    -len : int

    -*bin :int

    +<<constructor>> UINT(:int,int=16 )

    +toint() : int

    +add(:UINT) :UINT




    *int type variables can be replaced with short.

    Fig. 1. UML Diagram of class UINT

    Write main function to test the supposed capability of your program and attached the screenshot of the results on your report. For, example if you have mechanism that prevent overflow error, demonstrate it in your main function.

  2. #2
    Join Date
    Oct 2007
    Inside my computer
    Well, what do you not understand?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Join Date
    Dec 2007
    He understands cross-posting, that's for sure.

  4. #4
    Registered User
    Join Date
    Oct 2008
    ok some part that i don't understand is making the 'skeleton' of the program and differentiation of signed and unsigned ..
    i didn't learnt that yet and still the lecturer asks for this in my assignment

  5. #5
    Join Date
    Dec 2007
    So how about you ask the lecturer about it? If the lecturer is assigning problems related to unsigned/signed overflow, don't you think you should get that information from him/her?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. One Easy" C " Question. Please Solve and Explain.
    By RahulDhanpat in forum C Programming
    Replies: 18
    Last Post: 03-24-2008, 01:39 PM
  3. Replies: 4
    Last Post: 11-19-2002, 09:18 PM
  4. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM
  5. question once again..
    By sunnycyboid in forum C Programming
    Replies: 1
    Last Post: 11-08-2002, 04:57 AM