fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. class pixel
  7. {
  8. public:
  9. pixel(void) : R(0), G(0), B(0)
  10. {
  11.  
  12. }
  13. pixel(int R, int G, int B) : R(R), G(G), B(B)
  14. {
  15.  
  16. }
  17. void showPixel(void)
  18. {
  19. cout<<"R: "<<R<<"\tG: "<<G<<"\tB: "<<B<<endl;
  20. }
  21. private:
  22. int R;
  23. int G;
  24. int B;
  25. };
  26.  
  27. int main(void)
  28. {
  29. vector<pixel> test;
  30. test.push_back(pixel(1,2,3));
  31. // test.insert(pixel(1,2,3));
  32. cout<<test.size()<<endl;
  33. test[0].showPixel();
  34.  
  35. test[0]=pixel();
  36. cout<<test.size()<<endl;
  37. test[0].showPixel();
  38. }
  39.  
Success #stdin #stdout 0.01s 2860KB
stdin
Standard input is empty
stdout
1
R: 1	G: 2	B: 3
1
R: 0	G: 0	B: 0