Thread: value,reference,pointer

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    14

    Question value,reference,pointer

    hi, i need some advise i have find the hypotenuse,passing three different ways,by value,pointer and reference. i know that c2=a2+b2 but i don't know how to start, any ideas will be aprreciated.

    thanks

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    well if you have to pass all three ways that means you're using functions....

    You're probably going to use atleast one function for the calculations, what do you want that function to do? What would the decleration of that function be?

    maybe something like this:

    float calchypt(Pass the legs in here);

    with it actaull being:

    Code:
    float calchypot(Pass atleast the legs in here)
    {
      
      float temp = leg1^2 + leg2^2;
       
       hypot=sqrt(temp);
      
             //now if you declared hypot in this function, 
             //then you'll want to return it here
    }
    Take note that was just psudo code...some of the things like square root and squared you'll need from an include (I think it's math.h) and I'm not 100% sure on thte syntax there.


    Kermi3
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    14

    Smile

    that was fast, thanks,yes the psudo code is now <cmath>for c++.net, i'll fallow your example

  4. #4
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    it's always easier than it first looks, if your lucky...I've always found that I just have to lay it all out and look @ it.
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

Popular pages Recent additions subscribe to a feed