use of STL has problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • digituner
    New Member
    • May 2007
    • 2

    use of STL has problems

    I defined axFx class like this :

    Code:
    class axFx : public Object
    {
    private:
    	int ef_index;
    	char* ef_filename;
    	int noframes;
    	int ident;
    public:
    	axFx();
     	void SetNofFrame(int p) { noframes = p; }
     	int GetNofFrames() { return noframes; }
    	void SetFilename(char* filename);
    	char* GetFilename() { return ef_filename; }
    	int GetIndex() { return ef_index; }
    	int GetIdent() { return ident; }
    	void SetIdent(int p) { ident = p; }
    	//void SetOrder(int* p) {};
    	void SetIndex(int p) { ef_index = p; }
    };
    and this code has some problems
    Code:
                    axFx* fx = new axFx();
                    ... // define instance "fx"
    		fx_col.push_front(*fx);
                   delete fx;
    the problem is on about list container class defined by "list<axFx> fx_col;" (it's a member of some class)

    I pushed "fx" from front, but "fx_col" doesn't accept this. still "fx_list._S ize" is gain one. but "fx_list.begin( )" (it's expample for first element of list.) has all member vars with -842150451or 0xcdcdcdcd.

    what does it means? plz help some advices ;(
  • AdrianH
    Recognized Expert Top Contributor
    • Feb 2007
    • 1251

    #2
    You are stating that fx_col is a list<axFx>, but axFx doesn’t define a copy constructor, so it would create a member-wise copy. This is more than a little dangerous as you have a pointer in axFx.

    That not withstanding, I’m not sure what you mean by “I pushed "fx" from front, but "fx_col" doesn't accept this.” Do you get a compilation error? How do you know it is not being accepted?


    Adrian

    Comment

    • digituner
      New Member
      • May 2007
      • 2

      #3
      I solved this problem now. (it's because I dunno about STL.)
      I used context viewer in vc++ 6 for watch memory status.
      and I saw _Head has stupid offset and values. but I misunderstood the offset what fx_list.begin() returns. finally, _Head is does not seem to be outside users... of course.
      thx for your answer.

      Comment

      • AdrianH
        Recognized Expert Top Contributor
        • Feb 2007
        • 1251

        #4
        Good that you figured it out. Enjoy your victory.


        Adrian

        Comment

        Working...