Q:

Pre-made instances of a class

I have class like this:
class result{
public:
    int a;
    int b;
    int c;
};

a,b,c can be filled with any integer. However, there is some famous cases which I will use them too much like for example the zero case where (a=b=c=0) or the identity case where (a=b=c=1) and some others.
So I want an easy way to get this instances when I want one of them without creating new object and filling it manually (the real case contains much more complex that 3 integers).
What I am doing currently is like this:
class result{
public:
    int a;
    int b;
    int c;
    static result get_zero(){
         return result{0,0,0};
    }
    static result get_idenity(){
         return result{1,1,1};
    }
};

and in main:
auto id=result::get_identity();

Is this a good way to achieve what I want? Is there like an idiomatic way for doing this?

A:

If the objects can be modified after you return them, then yes, this is the correct way, since you cannot share a single object.
NRVO (http://en.cppreference.com/w/cpp/language/copy_elision) and move-semantics remove any cost associated with returning the object by value.
If you know these objects will never be changed, you can return a result const & instead and have the object itself be a static member of your class.  At that point, you don't even technically need the getter/setter, since the static members are public and already marked as const.
class result{
public:
    int a;
    int b;
    int c;
    static result const zero_result{0,0,0};
    static result const & get_zero(){
         return result::zero_result;
    }
    static result const identity_result{1,1,1};
    static result const & get_idenity(){
         return result::identity_result;
    }
};

don't forget to allocate the memory for your static data members in a .cpp file, though:
result const result::zero_result;
result const result::identity_result;

