I have a question about this particular code.
The structs would not save the value entered by the user into its class' attributes.
If you do not understand what i am talking about, please compile the code below. Can someone kindly explain what is the problem and how to fix it? Thank you for your time.

Code:
#include <iostream>
#include <string>

using namespace std;

class Sam
{
    struct sample{
        int a;
        string b;
        };

    public:

        void set_a();
        void set_b();
        int ret_a();
        string ret_b();
};


void Sam::set_a()
{
    int a1;
    cout<<"Insert int a";
    cin>>a1;
    sample().a=a1;
}

int Sam::ret_a()
{
    return sample().a;
}

void Sam::set_b()
{
    string b1;
    cout<<"Insert string b";
    cin>>b1;
    sample().b=b1;
}

string Sam::ret_b()
{
    return sample().b;
}

int main()
{
    Sam c;

    c.set_a();
    c.set_b();

    cout<<c.ret_a()<<endl<<c.ret_b();  //It should output the same value inputted by the user             
                                                             // but it shows nonsense. why is it so?
    return 0;
}