[ create a new paste ] login | about

Link: http://codepad.org/V5GBwMqo    [ raw code | output | fork ]

C++, pasted on Jan 2:
// 稚拙なプログラムですいません...
#include <vector>

#include<iostream>
using namespace std;

class CLASS_01{
	
	private :
		int i;
	
	public :
		CLASS_01(){
		}
		~CLASS_01(){
		}
	
	public :
		void input(int new_i){
			i = new_i;
		}
		void output(){
			cout << i << "\n";
		}

};

CLASS_01 *cl;

vector<CLASS_01> *vec = new vector<CLASS_01>;

void pop(){
	for(int i = 0;
	        i < vec -> size();
	        i++)
	{
		CLASS_01 c = (CLASS_01)vec->at(i);
		c.output();
	}
}

int main(){
	
	int num = 100;
	for(int i=0; i<5; i++){
		
		cl = new CLASS_01[i];		
		cl[i].input(num);
		
		
		vec -> push_back(cl[i]);
		
		
		num += 50;
	
	}
		
	cout << "一回目の実行\n";	pop();

	vector<CLASS_01>::iterator it = vec -> begin();
	it += 2;
	it = vec->erase(it);
	
	
	cl = new CLASS_01[5];
	cl[5].input(75);
	
	it = vec->insert(it, cl[5]);
	
	
	cout << "二回目の実行\n";	pop();
	
	
	
	delete [] cl;
	
	return 0;
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'void pop()':
Line 34: warning: comparison between signed and unsigned integer expressions


Create a new paste based on this one


Comments: