deleting dynamic object problem

This is a discussion on deleting dynamic object problem within the C++ Programming forums, part of the General Programming Boards category; You do Code: sensors[num]->PrintInformation(); // Implementation void Derived::PrintInformation() { cout << "Air temperature: " << GetAirTemp() << endl; cout << ...

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You do
    Code:
    sensors[num]->PrintInformation();
    
    // Implementation
    void Derived::PrintInformation() {
       cout << "Air temperature: " << GetAirTemp() << endl;
       cout << "Wind speed: " << GetWindSpeed() << endl;
       cout << "Wind direction: " << GetWindDir() << endl;
       cout << "Sea temperature: " << GetSunInt() << endl; 
       cout << "Longitude " << GetLong() << endl;
       cout << "Latitude " << GetLat() << endl;
    }
    After all, that's what object orientation is about.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Code:
    sensors[num]->PrintInformation();
    
    // Implementation
    
    void Base::PrintInformation() {
       cout << "Air temperature: " << GetAirTemp() << endl;
       cout << "Wind speed: " << GetWindSpeed() << endl;
       cout << "Wind direction: " << GetWindDir() << endl;
    }
    
    void Derived1::PrintInformation() {
       Base::PrintInformation();
       cout << "Sea temperature: " << GetSunInt() << endl; 
    }
    
    void Derived2::PrintInformation() {
       Base::PrintInformation();
       cout << "Oxygen content: " << GetOxyContent() << endl;
    }
    That should work too
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #18
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    thank you to everyone who helped me on this. I've now got it working and learnt a lot in the process.
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-07-2009, 05:51 PM
  2. Problem accessing calling object members- please help
    By Tiansen in forum C++ Programming
    Replies: 7
    Last Post: 11-11-2008, 06:07 AM
  3. Template object creation problem
    By babu198649 in forum C++ Programming
    Replies: 7
    Last Post: 09-16-2008, 04:02 AM
  4. Dynamic Array Problem
    By adc85 in forum C++ Programming
    Replies: 2
    Last Post: 03-04-2003, 01:29 PM
  5. dynamic object initialisation??
    By splendid bob in forum C++ Programming
    Replies: 2
    Last Post: 07-04-2002, 12:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21