#include <iostream>
#include <string.h>
using namespace std;
class A
{
private:
int a;
int b;
public:
A():a(10),b(20){};
A(int ad,int bd):a(ad),b(bd){};
void printvalues()
{
cout<<a << " " <<b<<endl;
}
};
int main()
{
A a(5,12);
memset(&a,sizeof(A),0);
a.printvalues();
return 0;
}
memsetting the object to 0, do not seem to have any effect on the object. Can anyone help me understand this behavior. output: 5 12
You have the arguments to memset the wrong way round. It's memset(addr, value, number).
memset is usually avoided.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With