fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <string>
  4. #include <fstream>
  5. #include <list>
  6. using namespace std;
  7.  
  8. class test
  9. {
  10. private:
  11. string code;
  12. int digit;
  13.  
  14. public:
  15. //constructor
  16. test(): code(""), digit(0) { }
  17.  
  18. //copy constructor
  19. test(const test &other):
  20. digit(other.digit)
  21. {
  22. for(unsigned int i=0; i < code.length(); i++)
  23. code[digit] = other.code[digit];
  24. }
  25.  
  26. //set up the private values
  27. void setCode(const string &temp, const int num);
  28. void setDigit(const int &num);
  29.  
  30. //return the value of the pointer character
  31. const string &getCode() const;
  32. const unsigned int getDigit() const;
  33. };
  34.  
  35. const string& test::getCode() const
  36. {
  37. return code;
  38. }
  39. const unsigned int test::getDigit() const
  40. {
  41. return digit;
  42. }
  43. void test::setCode(const string &temp, int num)
  44. {
  45. code[num] = temp[num];
  46. }
  47. void test::setDigit(const int &num)
  48. {
  49. digit = num;
  50. }
  51.  
  52.  
  53. int main()
  54. {
  55. string contents = "dfskr-123";
  56.  
  57. test aisbn;
  58. list<test> simul;
  59. list<test>::iterator testitr;
  60. testitr = simul.begin();
  61. int count = 0;
  62.  
  63. cout << contents << '\n';
  64. aisbn.setCode(contents, count);
  65. aisbn.setDigit(count);
  66. simul.push_back(aisbn);
  67. count++;
  68.  
  69. /*for(; testitr !=simul.end(); simul++)
  70.   {
  71.   cout << testitr->getCode() << "\n";
  72.   }*/
  73.  
  74. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
dfskr-123