how do i declare array of pointers to base clase reobject

This is a discussion on how do i declare array of pointers to base clase reobject within the C++ Programming forums, part of the General Programming Boards category; #ifndef REDBASE_H #define REDBASE_H #include <iostream.h> #include <fstream.h> #include "reobject.h" #include "onefamily.h" class redbase { public: redbase(char * file) //Opens ...

  1. #1
    icantprogram
    Guest

    Post how do i declare array of pointers to base clase reobject

    #ifndef REDBASE_H
    #define REDBASE_H
    #include <iostream.h>
    #include <fstream.h>


    #include "reobject.h"
    #include "onefamily.h"

    class redbase {
    public:
    redbase(char * file) //Opens file
    {

    file = "property.dat";
    ifstream infile;
    cout<<"\nPlease enter the input file name \n(need including the file extention): ";
    cin>>file;
    fp = file;

    }



    private: reobject *baseptr[100];//Is this Array of pointers to base class?? HELP ME??
    char *fp;

    baseptr baseptr+1;





    };

    #endif


    //I NEED TO DECLARE AN ARRAY OF POINTERS TO REOBJECT
    //HOW DO I DO THAT//

    //I ALSO NEED TO CREATE ANOTHER PRIVATE MEMBER THAT CONTAINS THE INDEX OF THE NEXT AVAILABLE EMPTY CELL IN THE ARRAY OF POINTERS//

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    >reobject *baseptr[100];//Is this Array of pointers to base class?? HELP ME??

    yes, assuming reobject is your base class

    >baseptr baseptr+1;

    what is this for?


    //I ALSO NEED TO CREATE ANOTHER PRIVATE MEMBER THAT CONTAINS THE INDEX OF THE NEXT AVAILABLE EMPTY CELL IN THE ARRAY OF POINTERS//

    Please dont type in all caps. Just have an integer that increment everytime you fill a spot in the array.
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  3. #3
    icantprogram
    Guest

    Post

    how?
    it has to be a private member

  4. #4
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128
    Just declare the private member but also declare a public access method such as:

    Code:
    private:
    int nextcell;
    
    public:
    incrementcell();{nextcell++;}
    obviously slightly more complicated than that, but from what you have said That is how I would do it.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 10-21-2007, 08:44 AM
  2. Array of struct pointers - Losing my mind
    By drucillica in forum C Programming
    Replies: 5
    Last Post: 11-12-2005, 11:50 PM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 05:15 AM
  4. dynamic array of base class pointers
    By Corrington_j in forum C++ Programming
    Replies: 1
    Last Post: 11-16-2003, 05:58 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM

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