U E D R , A S I H C RSS

study C++/남도연

--------<munja.h>----------
~cpp 
class munja{
private:
	char a[50];
	int c;
public:
	munja();
	~munja();
	void input();
	friend void search(munja);
	void add(munja,munja);
	void repeat(munja);
};
------<munja.cpp>------------
~cpp 
#include "munja.h"
void main(){
	munja Mun;
	munja Mun2;
	Mun.input();
	search(Mun);
	Mun.add(Mun,Mun2);
	Mun.repeat(Mun);
}
------<munja2.cpp>----------
~cpp 
#include "munja.h"
munja::munja(){
	c=0;
}
munja::~munja(){
}
void munja::input(){
	cout<<"문자열을 입력하시오"<<endl;
	cin>>a;
}
void search(munja A){
	int i;
	char b;
	cout<<"찾을 문자는?"<<endl;
	cin>>b;
	for (i=0;i<50;i++){
		if (A.a[i]==b){
			cout<<"찾은 문자의 위치는 "<<i+1<<"입니다."<<endl;
		}
}
}
void munja :: add(munja A, munja B){
	B.input();
	cout<<"추가되어 완성된 문자열은"<<A.a<<B.a<<"입니다"<<endl;
}
void munja::repeat(munja C){
	int k;
	cout<<"반복할 횟수를 입력하세요"<<endl;
	cin>>C.c;
	for (k=0;k<C.c;k++){
		cout<<C.a<<endl;
	}
}


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:45
Processing time 0.0147 sec