Results 1 to 10 of 14

Thread: [C] The lousy random question thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts

    [C++] methods excurs

    Hey, its me again..

    PHP Code:
    type foobar()
    {
        return (
    type)1337;
    }

    class 
    myClass
    {
        public:
            
    type x;

            
    type foobarfloat value )
            {
                
    type t value 2;
                
    std::cout << "type foobar( float value )" << std::endl;
                return 
    t;
            }

            
    void foobarfloat value )
            {
                
    value;
                
    std::cout << "void foobar( float value )" << std::endl;
            }
    };

    float tmp;
    myClass c1 c2;

    foobar(); //calls function but returnvalue isnt used
    tmp c1.foobar42 );//calls methods
    c2.foobar42 ); //does the compiler use the method without a returnvalue? 
    i know that the compiler generates different function-identifiers for both methods (different in and output types)

    but my question is: does the compiler/cpu know when to use a method with or without the returnvalue?



    EDIT
    maybe these console prints will brigthen things up
    Last edited by serthy; 2nd August 2013 at 21:04.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •