This is a simple thing that I'm not sure if it is possible in C++ like in some other languages. The thing behaves like it is a copy, but not the same object. I would expect that if this was struct, or some other value type - this would be expected behaviour, but for class, I expected this to behave like I'm looking at "reference", that is - the same object as is in array. What am I doing wrong?
// Example program
#include <iostream>
#include <string>
class someclass
{
    public:        
    void setn(int n2);
    int n=10;
};
void someclass::setn(int n2){
    n=n2;
};
int main()
{
  someclass moreofthem[5];   
  someclass my=moreofthem[1];  
  std::cout << "start value: " << my.n << " as inital\n"; //10
  my.setn(2);  
  std::cout << "new value: " << my.n << " as expected\n"; //2
  std::cout << "value in list: " << moreofthem[1].n << " why?\n";  //10?
}
 
     
     
     
     
    