C++ variable scope and mutexes

I've been wondering if I can make mutexes much easier to use in C++ with creative use of a locking class and variable scope, but I'm not sure if things happen in the order I want. Here's pseudocode for something that could use the class:

int someclass::getvalue()
{
  int retval;
  MutexWait(lock);
  retval=value;
  MutexPost(lock);
  return(retval);
}

Here's pseudocode for the locking class:

class getmutex
{
private:
  mutex lock;
public:
  getmutex(mutex lock_in)
  {
    lock=lock_in;
    MutexWait(lock);
  }

  ~getmutex()
  {
    MutexPost(lock);
  }
};

The idea being, when the class goes into scope, the mutex gets locked, and when the variable goes out of scope, the mutex gets unlocked.

Here's the code using this class:

int someclass::getvalue()
{
  grabmutex glock(lock);
  return(value);
}

Will this work the way I hope it will? Will glock go out of scope before or after 'value' is read?