Results 1 to 10 of 14

Thread: [C] The lousy random question thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    not having a compiler atm xD

    (edited the question above)


    EDIT:
    http://www.compileonline.com/compile_cpp_online.php
    main.cpp:21:10: error: 'void myClass::foobar(float)' cannot be overloaded
    main.cpp:14:13: error: with 'myClass myClass::foobar(float)'
    Code:
    #include <iostream>
    
    bool foobar( float x )
    {
        std::cout << "" << std::endl;
        return true;
    }
    
    class myClass
    {
        public:
    
        myClass foobar( float x )
        {
            std::cout << "myClass foobar()" << std::endl;
    
            return myClass();
        }
    
        void foobar( float x )
        {
            std::cout << "void foobar()" << std::endl;
    
        }
    };
    
    int main( int argC , char* args[] )
    {
        myClass c1 , c2 , c3;
    
        foobar( 0.0f );
        c1.foobar( 0.0f );
        c2 = c3.foobar( 0.0f );
    }
    Last edited by serthy; 2nd August 2013 at 21:13.

  2. The Following User Says Thank You to serthy For This Useful Post:

    kung foo man (2nd August 2013)

  3. #2
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    next 'problem':

    i've got a struct including an array
    this array should be variable in its length , but <= MAX_LENGTH

    PHP Code:
    #define MAX_LENGTH 256

    struct myStruct
    {
        
    int array[MAX_LENGTH];
    }; 
    infact this struct is now filled with 256 unused integers
    how do i get anything similar to this without having a big empty array?

    EDIT:
    and i dont want to allocate new memory for every single input
    so neither 'int* array;' nor 'int array[];' will work without that and without using static construction like: 'struct myStruct s = { 1 , 2 , 3 };'
    Last edited by serthy; 15th August 2013 at 20:27.

Posting Permissions

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