5월27일 C++(순수가상함수,sort,setf(ios_base::boolalpha,showpos,hex,width)API(비트맵뷰어)
2010. 5. 27. 08:59ㆍ2010년/5월
반드시 자식 클래스는 부모클래스의 vitual되어있는 함수를 구현해야한다.
그것이 바로 순수가상함수라는것이다.
보다 시피 itisn에서 virtual void test()함수를 만들고 뒤에 0을 넣었다.
그러면 자식이되는 sca에서 test()함수를 반드시 구현해야한다.
만약에 sca test()함수 자체를 빼거나 주석처리하게 되면 에러가 뜬다.
이는 개발자의 의도 하는것이다.
뭐 강제적으로 하는것이니깐.
Sort
다른내용은없다 기본적으로 캐릭터 배열에서 들어간 내용을 알파벳 순서에 맡게 정렬하는내용이다
여기서 string을 넣고 sort()를 사용했다.
sort의 첫번째 인자는 시작주소이고 마지막 인자는 끝주소이다
그래서 첫인자로 String을넣었고
마지막 주소를 sizeof(String)-1로 넣어서 했더니 결과값이
이렇게 나왔다.
#include<iostream>
#include<list>
//연결리스트
using namespace std;
int main()
{
std::list<int>intList; //표준템플릿 라이브러리를 선택해서 int형으로 intList 연결리스트 만듬
for(int i=0;10>i;++i)
{
intList.push_back(i); //연결리스트계속 꼬리 물듯이 뒤로 붙음
}
intList.remove(5); //해당되는 찾아서 삭제 즉 5가 삭제..
std::list<int>::iterator it;
for(it=intList.begin();it!=intList.end();++it) //begin()연결리스트의 제일 시작주소
{
std::cout<<*it<<endl;//객체의 데이터를 뽑아낸다. <<는 연산자 오버로딩
}
return 0; //연결리스트가 자동으로 정리가 된다.
}
================================================================
================================================================
#include<iostream>
using namespace std;
int main()
{
ios_base::fmtflags Old;
cout<<true<<endl;
cout.setf(ios_base::boolalpha);
cout<<true<<endl;
cout.unsetf(ios_base::boolalpha);//해제
cout<<boolalpha<<true<<endl;//일회용
//*******************************************************
cout<<10<<endl;
cout<<-10<<endl;
cout.setf(ios_base::showpos);
cout<<10<<endl;
cout<<-10<<endl;
cout.unsetf(ios_base::showpos);//해제
cout<<showpos<<10<<endl; //일회용
//*******************************************************
cout<<99<<endl;
cout.setf(ios_base::hex,ios_base::basefield);
cout<<99<<endl;
cout.setf(Old,ios_base::basefield);//해제
cout<<hex<<99<<endl; //일회용
cout<<dec<<99<<endl;
//*******************************************************
cout.width(10); //일회용
cout<<100<<endl;
cout.fill('*'); //별붙이기
cout.width(10); // 일회용
cout<<100<<endl;
//*******************************************************
cout<<true<<endl;
cout<<10<<endl;
return 0;
}
'2010년 > 5월' 카테고리의 다른 글
5월31일 API(비트맵뷰어) RFID(윈도우 단축키!!! (0) | 2010.05.31 |
---|---|
5월28일(비트맵뷰어회전)C++(hexaviewer c++로 변환 (0) | 2010.05.28 |
5월26일 C++(템플릿함수,inline,클래스밖 함수구현템플릿,virtual 객체기반)API(비트맵뷰어) (0) | 2010.05.26 |
5월25일 C++(복사생성자,대입연산자,종속대입연산자.종속복사생성자,템플릿)API(simplepaint2) (0) | 2010.05.25 |
5월24일 C++(SmartPointer,namespace,연산자오버로딩 API(대화상자 후반부) (0) | 2010.05.24 |