0

Why does this ZeroMemory(&socketAddress, sizeof(Connection::socketAddress)); work, but this doesn't?

ZeroMemory(&Connection::socketAddress, sizeof(Connection::socketAddress));

I get this error: error C2664: 'memset' : cannot convert parameter 1 from 'sockaddr_in Connection::* ' to 'void *'

user207421
  • 298,294
  • 41
  • 291
  • 462
tr0yspradling
  • 417
  • 1
  • 8
  • 20

1 Answers1

2

&Connection::socketAddress is a member pointer. It's not itself a pointer, but a way to get a pointer to a particular member of a class given a pointer to that class. ZeroMemory can't accept it because it doesn't actually point to any real memory; it needs more information (a pointer to the instance of the class containing the member) before it can actually get a real pointer.

Take a look at this question for more information about member pointers.

Community
  • 1
  • 1
icktoofay
  • 122,243
  • 18
  • 242
  • 228