|
우와 답변바로 와 굳~~~~~~~~
정말 감사합니다.
insa *Temp = *it; 썼을경우
'insa'에서 'insa *'(으)로 변환할 수 없습니다.에러가 나는데...
또
printf("%s\n",(it->name)); // ddd 라는 null 이 나옵니다.;;;
너무...초보라.. 죄송합니다.;;;
Lyn 님이 쓰신 글 :
: insa *Temp = *it; 이런식으로 대입은 불가능한지...
:
: 초보자 님이 쓰신 글 :
: : ㅋㅋㅋ 감사합니다.;;
: : printf("%d\n",(it->birth));
: : 하니까 되네요.. 감사합니다.
: : 그런데 대입해서 나오는게 하려면..
: :
: : 예를 들어
: :
: : insa *Temp = (dynamic_cast<insa &>(*it)); 이런식으로 대입은 불가능한지...
: :
: :
: : Lyn 님이 쓰신 글 :
: : : 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;
: : : : : : }
: : : : : :
: : : : : : 혹시 아시는분 답변주시면 감사드리겠습니다.
|