Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The C++

Name: Anonymous 2010-11-10 12:42

ENTERPRISE C++ uses templates and ambigious function names for EVERYTHING.


#include <iostream>
#include <vector>
#include <cstdio>

template<typename s_t> void _sv(s_t&_s,const s_t&_i){_s=static_cast<s_t>(_i);}
template<typename t_1> bool _isl(t_1&_1,t_1&_2){return(_1<_2);}
template<typename t_1>bool _ise(t_1&_1,const t_1&_2){return(_1==_2);}
template<typename t_1>void _ic(t_1&s,const t_1&v){(s=s+v);}
template<typename a_t>class c_1:public std::vector<a_t>{};
template<typename a_t, typename b_t> class _a{
    a_t a;
    a_t _1_i;
    b_t b;
    char* _c;
    c_1<std::string> _rs;
    public:
        _a(a_t _a, b_t _b): a(_a), b(_b)
        {
            int _h_i;
            _1_i=0;
            if(_ise(a,1)) goto _L0;
            for(_sv(_h_i,1);_isl(_h_i,a);_ic(_h_i,1))
            {
                _c=b[_h_i];
                _rs.push_back(_c);
            }
            _1_n(); return;
            _L0: printf("go cry in a corner\n");
        }
        void _1_n()
        {
            std::string _1_s;
            typename c_1<std::string>::iterator _hi;
            _hi=_rs.begin();
            _L1: if(_hi==_rs.end())return;
            _1_s=*_hi;
            printf("argv[%d] = %s\n", _1_i, _1_s.c_str());
            _hi++; _1_i++; goto _L1;
        }
};

int main(int a, char** b)
{
    _a<int,char**>(a,b);
}

Name: Anonymous 2010-11-12 21:59

>>31
In C++, the destructor is called as soon as the object goes out of scope.

In C, the destructor is never called as soon as the object goes out of scope, because
   1: C doesn't have a scope in the same meaning as in C++;
   2: Structs in C don't have destructors, which makes scopes already void and useless;
   3: you have to call myobj_destroy manually, which also makes 1 and 2 void and useless.

For example:

#include <cstdio>

class File {
    private:
        FILE* handle;

    public:
        File(const char* path)
        {
            handle = fopen(path, "w");
        }

        ~File()
        {
            close();
        }

        void close()
        {
            fclose(handle);
        }

        void write(const char* data)
        {
            fputs(data, handle);
        }
};

int main()
{
    File poop("things.txt");
    poop.write("hi");
    // no need to call 'poop.close()', as close() is called as soon as
    // poop goes out of scope
}


And now in C:
there is no C example, since C makes RAII impossible. it would be just the same with FILE* fopen(const char*, const char*) and void fclose(FILE*), without actually being able to call fclose upon destruction, as there is no such thing as ``destruction'', as in C++.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List