Thread: Simple OO Problem

  1. #1
    High School Coder
    Join Date
    Apr 2004
    Posts
    1

    Post Simple OO Problem

    Hi. I have written a class called TOC that implements a bunch of functions for connection to the AIM service and for handeling incoming IMs, etc. I decided that since I plan to use this in multiple programs, I would write a subclass of it and call it AIMBot. AIMBot just simply overrides a few functions dealing with the display and the message handling. Here is my problem: in the TOC class, when any type of message is recieved, it is sent to TOCServer(CString), which then decides what funciton to call based upon the header of the message. These functions that are called are already implemented within the same class. For instance, if a user sends a message to the screen name controled by a TOC instance, it is then sent to TOCServer(CString), then the appropriate function is called (in this case, it's doIM(CString) ). In TOC, all the doIM(CString) does is to display the message. I want to override this function. After implementing a new version in AIMBot, I saw no change in the program's behavior. It doesn't seem to be overriding. Am I making some type of simple OO mistake? Bad assumption? You guys tell me. Thanks in advanced for any help.
    ~Brian Stempin

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    It sounds like you need to declare the method as virtual in the base class. Then your overridden behavior should work out.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple file I/O problem
    By eecoder in forum C Programming
    Replies: 10
    Last Post: 10-16-2010, 11:00 PM
  2. Simple Gets() problem
    By akira181 in forum C++ Programming
    Replies: 17
    Last Post: 05-25-2006, 03:28 AM
  3. Problem in simple code.
    By richdb in forum C Programming
    Replies: 6
    Last Post: 03-20-2006, 02:45 AM
  4. Problem in very simple code
    By richdb in forum C Programming
    Replies: 22
    Last Post: 01-14-2006, 09:10 PM
  5. Simple Initialization Problem
    By PsyK in forum C++ Programming
    Replies: 7
    Last Post: 04-30-2004, 07:37 PM