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

Pure OOP Sepples

Name: Anonymous 2011-12-25 21:23

Basically, trying to define a set of types to replace the standard int, char, float, etc... to make C++ more like Ruby. This is what I have so far... not sure what to name a namespace other than perhaps POOP (Pure Object Oriented Programming... obviously very unprofessional), so I haven't tossed them in a namespace yet.

#include <stdint.h>
#include <string>
#include <sstream>

class Int_Obj {
        int32_t Data;
        Int_Obj(int32_t argument) { Data = argument; }
public:

        Int_Obj() {}
   
        Int_Obj operator + (int32_t arg) { return Int_Obj(arg + Data); }
        Int_Obj operator + (Int_Obj arg) { return Int_Obj(arg.Data + Data); }
        Int_Obj operator - (int32_t arg) { return Int_Obj(Data - arg); }
        Int_Obj operator - (Int_Obj arg) { return Int_Obj(Data - arg.Data); }
   
        void operator =  (int32_t arg) { Data = arg; }
        void operator =  (Int_Obj arg) { Data = arg.Data; }
        void operator += (int32_t arg) { Data += arg; }
        void operator += (Int_Obj arg) { Data += arg.Data; }
        void operator -= (int32_t arg) { Data -= arg; }
        void operator -= (Int_Obj arg) { Data -= arg.Data; }
        void operator ++ () { Data++; }
        void operator -- () { Data--; }

        std::string to_s() {
                std::ostringstream out;
                out << Data;
                return out.str();
        }
};


Anyways, any suggestions on what else I might need to add, or how to implement things like Ruby's arrays (can store any number of any types of objects, and are safe from memory leaks)... obviously void pointers aren't exactly an option.

Name: Anonymous 2011-12-26 20:57

>>26
I brought up rails because it's the most common Ruby framework. More Ruby code is written with it than without, or was the last time I checked. You don't need to target the web just to use a framework.

Anyway you seem bent on fagging up whatever your working with so you might as well stick with C++. When you finally make integers, floats and pointers into objects you'll be somewhere between the speed of rails and plain Ruby.

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