|
birth 군요 =_=;;
그정도는 알아서 커버 하심이 ㅡ.ㅡ;
초보자 님이 쓰신 글 :
: 답변 정말 감사드립니다.;;;
: 그런데.. 에러가..
: 1> error C2039: 'Birth' : 'insa'의 멤버가 아닙니다.
: 1> 'insa' 선언을 참조하십시오.
:
: Lyn 님이 쓰신 글 :
: : printf("%d\n",*(it->Birth));
: :
: : 초보자 님이 쓰신 글 :
: : : 안녕하세요.. 초보자 입니다.
: : : STL 관련 하여.... 책보면서.. 바꾸면서 이거 저거 해보려고 하는데..
: : : 에러가 나서 이렇게 여쭤보게 되었습니다.
: : : 두가지 여쭤볼게...
: : :
: : : #include "stdafx.h"
: : : #include <iostream>
: : : #include <string>
: : : #include <list>
: : :
: : : using namespace std;
: : :
: : : class CList_Class
: : : {
: : : public :
: : : CList_Class(void ){};
: : : ~CList_Class(void ){};
: : : int ValueT;
: : :
: : : };
: : :
: : : struct insa
: : : {
: : : long birth;
: : : string name;
: : : };
: : :
: : :
: : :
: : : int _tmain(int argc, _TCHAR* argv[])
: : : {
: : :
: : :
: : : list<CList_Class> *Value = new list<CList_Class>();
: : : list<CList_Class>::iterator it;
: : :
: : :
: : :
: : : CList_Class *newValue = new CList_Class();
: : : newValue->ValueT = 1;
: : :
: : : Value->push_back(const_cast<CList_Class &>(*newValue) );
: : :
: : : printf("%d\n",Value[0]); << 하나는 여기에 값이 0 이 나오는데
: : : for (list<CList_Class>::iterator it = Value->begin(); it != Value->end(); it++)
: : : {
: : : printf("%d\n",*it); 여기서는 정상적으로 나옵니다.
: : : }
: : :
: : :
: : : list<insa> *Tempvalue = new list<insa>();
: : :
: : : insa *sfsf =new insa();
: : :
: : : sfsf->name = "ddddd";
: : : sfsf->birth=12323;
: : :
: : :
: : : Tempvalue->push_back(const_cast<insa &>(*sfsf));
: : :
: : : for (list<insa>::iterator it = Tempvalue->begin(); it != Tempvalue->end(); it++)
: : : {
: : : printf("%d\n",*it); 여기서는 정상적으로 나옵니다. 단 하나만 나오고 안나옵니다.
: : : insa *Temp = (dynamic_cast<insa &>(*it)); //그래서 이렇게 써봤는데.. 에러가 납니다.
: : : printf("%s\n",Temp->birth);
: : : }
: : :
: : : delete Value;
: : : delete sfsf;
: : : delete Tempvalue;
: : :
: : : return 0;
: : : }
: : :
: : : 혹시 아시는분 답변주시면 감사드리겠습니다.
|