title: How do I overload the assignment operator as to allow my class to equal a primitive type such as 'int'
body: <p>So I am trying to do a program that is simply overloading many operators, but for some reason whenever I try to overload the assignment operator, I get an error that says</p>
  
  <blockquote>
    <p>error: conversion from 'int' to non-scalar type 'Foo' requested</p>
  </blockquote>
  
  <pre><code>    class Foo {
          int value;
      public:
          operator int() const;
          Foo&amp; operator=(const int &amp;val) { value = val; return this; }
          ...
      };
      int main()
      {
          Foo a = 8, b = 9;
          ...
          return 0;
      }
  </code></pre>
  
  <p>I have also tried it without the operator= statement and without the operator int() const; statement, but I just can't seem to get it to compile.</p>