the following code gives me the error: "expected constructor, destructor, or type conversion before ';' token", for both of the operator= lines. I'm trying to make it so the class my_int can be set equal to an int and an int can be set equal to my_int (i know i don't need a my_int class if it just holds an int, i made it to show the problem).
//my int.h
#ifndef myint_h
#define myint_h
class my_int
{
public:
int val;
my_int(void);
~my_int(void);
};
operator=(const my_int& a,const int x);
operator=(const int& x,const my_int a);
#endif
//my int.cpp
#include "my int.h"
my_int::my_int(void)
{
val=0;
}
my_int::~my_int(void) {}
operator=(const my_int& a,const int x)
{
a.val=x;
}
operator=(const int& x,const my_int a)
{
x=a.val;
}
does anyone know why the compiler is giving me this error or how to fix it?