Thread: I Need Help

  1. #1
    Registered User
    Join Date
    Jan 2002

    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
    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
    Hannover, Germany
    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.


    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.

    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
    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