I Need Help

This is a discussion on I Need Help within the C++ Programming forums, part of the General Programming Boards category; ive been up for 2 days now. yes thats 48 hrs. my teach wants us to create a calculator that ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    17

    I Need Help

    ive been up for 2 days now. yes thats 48 hrs. my teach wants us to create a calculator that can do complex number. he wants use to have functions take in values, functions that take those values and do add, subtract, etc. BUT, he said to use structs for complex numbers. I HAVE NO IDEA WHAT HE MEANS. I HAVE NO IDEA WTF A STRUCT IS USED FOR. I M GONNA KILL MYSELF IF I CANT GET SLEEP SOON!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    A struct is a class with every member function/data public.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    a) I don't see a reason why you shouldn't be sleeping.

    b) A struct is a definition of a variable type that has more than one member and may have functions that operate on it.

    Example:

    struct Point
    {
    int x;
    int y;
    };

    int main()
    {
    Point p;

    p.x = 4;
    p.y = 7;

    return 0;
    }

    Obviously, each complex number has two parts, too. Both belong to the same variable.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Unregistered
    Guest
    the grunt work comes when you need to, depending on how functional you want the program to be, overload the various functions/operators, sometimes multiple times to allow for things like:

    complex + complex versus
    comple + int versus
    int + complex versus
    double + complex versus
    complex + double

    or else write templated functions to cover all the various possibilities,

    etc. for the -, *, / operators and whatever else.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21