Thread: possibly a stupid question about inheritance

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445

    possibly a stupid question about inheritance

    let's say I've got two classes: Socket and SecureSocket. SecureSocket is derived publicly from Socket, and both classes implement Send() and Recv() methods. Socket additionally implements RecvLine(), which calls Recv(), but SecureSocket does not. if I have a SecureSocket object, and I call RecvLine() on it, will it call the Socket version of Recv() or will it call the SecureSocket implementation?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You couldn't have written an example with classes foo and bar to check in the same time it took you to make this post?

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by tabstop View Post
    You couldn't have written an example with classes foo and bar to check in the same time it took you to make this post?
    I certainly could if I were on my dev computer, but I'm on my cell phone.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Elkvis View Post
    I certainly could if I were on my dev computer, but I'm on my cell phone.
    Oh. Well in that case, brewbuck's now-vanished post was the right answer: it depends on whether the function is virtual.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Actually, as long as that method is accessible it shouldn't matter whether the function is virtual.

    SecureSocket does not implement RecvLine, correct? If that's the case, then any call to RecvLine will call the base class version.

    Edit: I think I misunderstood the question. tabstop is right that Socket's RecvLine will call SecureSocket's Revc only if Recv is virtual in Socket.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Question Probably
    By Kyrin in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 12:51 AM
  2. Replies: 7
    Last Post: 11-04-2005, 12:17 AM
  3. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  5. stupid question
    By maes in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 11-08-2001, 11:48 AM