Passing though a function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Passing though a function

RykonRykon Posts: 10Member
How can I make a new function and pass a var. through it?
«1

Comments

  • BrutesBrutes Posts: 162Member
    Hi Rykon

    They called Methods Rykon.

    I am not sure how you mean make a function?
    Can you tell me what it is you need to do?
    You need a basic structure of a method and how to call it?
  • RykonRykon Posts: 10Member
    My question is for this type of example in C++

    Int myfunction(int hi)
    {
    int j;
    j = hi + 2;

    Return hi;
    }
    then calling it
    int h = 4;
    myfunction(h)

    I can not get the "myfunction(h)" to pass into "myfunction9int (hi)"




  • lyubolyubo Posts: 17Member
    [b][red]This message was edited by lyubo at 2003-5-2 9:7:4[/red][/b][hr]
    : My question is for this type of example in C++
    :
    : Int myfunction(int hi)
    : {
    : int j;
    : j = hi + 2;
    :
    : Return hi;
    : }
    : then calling it
    : int h = 4;
    : myfunction(h)
    :
    : I can not get the "myfunction(h)" to pass into "myfunction9int (hi)"
    keke, in the example you provided, you return the same variable you've put as parameter, unmodifyed.
    Anyway I've, a little bit, forgotten c++, try calling myfunction from other function. Is myfunction in the global(is global function) namespace?

    Furthermore, you should try addressing your question in the C++ Forum ;-)

  • RykonRykon Posts: 10Member
    : keke, in the example you provided, you return the same variable you've put as parameter, unmodifyed.
    : Anyway I've, a little bit, forgotten c++, try calling myfunction from other function. Is myfunction in the global(is global function) namespace?
    :
    : Furthermore, you should try addressing your question in the C++ Forum ;-)
    :

    First I was doing a compare to c++ and the code was psuedo. You where no help to my question, read the first post.

  • lyubolyubo Posts: 17Member
    : : keke, in the example you provided, you return the same variable you've put as parameter, unmodifyed.
    : : Anyway I've, a little bit, forgotten c++, try calling myfunction from other function. Is myfunction in the global(is global function) namespace?
    : :
    : : Furthermore, you should try addressing your question in the C++ Forum ;-)
    : :
    :
    : First I was doing a compare to c++ and the code was psuedo. You where no help to my question, read the first post.
    :
    :
    Sorry, thought, I didn't see the comparement.
  • RykonRykon Posts: 10Member
    [b][red]This message was edited by Rykon at 2003-5-2 9:51:26[/red][/b][hr]
    That is ok, I was giving an example in c++ and I was wonder the C# equiv. Might I add I need it to work with a static and an object.


  • lyubolyubo Posts: 17Member
    [b][red]This message was edited by lyubo at 2003-5-2 10:1:34[/red][/b][hr]
    : [b][red]This message was edited by Rykon at 2003-5-2 9:51:26[/red][/b][hr]
    : That is ok, I was giving an example in c++ and I was wonder the C# equiv. Might I add I need it to work with a static and an object.
    :
    :
    :
    I'll try to give an example of what I think you are trying to express (hopefully, if we are both lucky, i will not be wrong ;))
    using System;
    namespace MyTestSpace
    // namespace
    {
    // simple SHOWOFF class
    public class WhatACalculator
    // class
    {
    // simple static method
    public static int Add(int fNum,int lNum)
    // method
    {
    // add the two values and return the result;
    return fNum+lNum;
    } // end method
    static void Main()
    { // method
    int myAge=18; // yes i'm 18
    int myGirlFriendsAge=16; // no, my girlfriend's is not 16
    int myMomsAge= // because my mom's age is 35 ;-)
    // calling the static add method, we don't need an object instance forIt
    WhatACalculator.Add(myAge,myGirlFriendsAge);
    // display the result from the Add method usage;
    Console.WriteLine(myMomsAge.ToString());
    } // end method
    } // end class
    } // end namespace


  • RykonRykon Posts: 10Member
    There is one problem with this code, it is not that same (to my knowlege) as one needed for a Windows app, not a console app. The main diff that I can find is the passing through an object(i.e. no static). Could you be any help on that?
  • lyubolyubo Posts: 17Member
    : There is one problem with this code, it is not that same (to my knowlege) as one needed for a Windows app, not a console app. The main diff that I can find is the passing through an object(i.e. no static). Could you be any help on that?
    :
    First - yes this is console demo app.
    Second what help exactly do you need, i'm confused now :)
  • RykonRykon Posts: 10Member
    Ok, I can make a console app and get methods to work, but when I try the same tactic on a windows app it will not work. The only difference that I can see it that I am trying to pass from a object(i.e. a method for a button) to a static method. Any idea of what I am talking about now?
«1
Sign In or Register to comment.