Re: Static members comparison

Discussion in 'C++' started by Victor Bazarov, Jun 24, 2003.

  1. "Dinesh Deva" <> wrote...
    > I have a class called Parser and a static member in it called Tree
    >
    > class Parser
    > {
    > public:
    > static Tree* ptree;
    > void parse();
    >
    > };
    >
    >
    > Now i build the tree in a variety of ways (parsing different) kinds of
    > files
    >
    > eg AParser, BParser deriving from Parser.
    >
    > I want to compare the trees built by AParser and BParser. If the tree
    > was not a static member, then i could do this.
    >
    > AParser ap;
    > ap.parse();
    >
    > BParser bp;
    > bp.parse();
    >
    > ap.ptree->compare(bp.ptree);
    >
    > But since it is static both the parsers will build the same tree.
    > (replace the old tree).
    >
    > How do i compare the trees?
    >
    > I know one way to do it is to do a deep copy of the tree. (this is the
    > long route).
    >
    > Is there any easier way?


    Make the parser compare as it builds? Move the 'ptree' out of
    the 'Parser' into 'AParser' and 'BParser'?..

    Victor
    Victor Bazarov, Jun 24, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    3
    Views:
    413
  2. SaravanaKumar
    Replies:
    6
    Views:
    9,366
    Tony Morris
    Oct 19, 2004
  3. JFCM
    Replies:
    4
    Views:
    5,724
  4. Rakesh Sinha
    Replies:
    4
    Views:
    1,842
    Rakesh Sinha
    Jan 13, 2005
  5. Hicham Mouline
    Replies:
    5
    Views:
    2,350
    James Kanze
    Dec 19, 2008
Loading...

Share This Page