![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2006
Posts: 8
Rep Power: 0
![]() |
question on sytnax...
if (connect(sock, (struct sockaddr *) &echoServAddr, sizeof (echoServAddr)) < 0)
std::cout<<"connect() failed.";My question is regarding the red text in the code above; it confused me. The book stated that because the socket api is generic, the pointer to the sockaddr_in address structure needs to be cast to the generic type (sockaddr). I can understand that but I dont understand the structure of this syntax. I'd be really grateful if someone can explain it, thanks. |
|
|
|
|
|
#2 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jul 2006
Posts: 8
Rep Power: 0
![]() |
Yeah, Im still green, but Im trying to work on that.. Thanks for your response.
can this be done using the "cast" keyword? |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Apr 2006
Posts: 155
Rep Power: 3
![]() |
There's no keyword cast.
You can find a complete list of all keywords here http://cppreference.com/keywords/index.html You may think of reinterpret_cast, dynamic_cast, const_cast or static_cast? You can use the above in this way: Type-of_cast<Type>(Expression);
__________________
-- v0id
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visual Basic 2005 Question | ReubenK | Visual Basic .NET | 3 | Apr 5th, 2006 4:23 PM |
| Attitudes | Oddball | Coder's Corner Lounge | 29 | Mar 18th, 2006 10:34 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 12:53 PM |
| How to post a question | nnxion | C++ | 0 | Jun 3rd, 2005 9:55 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 9:55 AM |