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
  • 305,947
  • 44
  • 307
  • 483
tr0yspradling
  • 529
  • 1
  • 9
  • 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
  • 126,289
  • 21
  • 250
  • 231