#include<iosream>
using name std;
class test
{
public:
int data; // This should probably be private
}; // you forgot your semi-colon here
int main()
{
test A;
A=10; // 'A' is the object, what you want to do is assign one of the objects members a value
A.data = 10; // Use the dot operator
}
You should probably also use a setter function rather than manually assigning it the value.
could you explain little bit. it works fine for me but it will be great if you provide littlbe explain
about the code
test &operator = ( int i )
{
data = i;
return *this;
}