So, it is necessary to transfer object by argument. I passed it, but in the method one field of the object should change. But after performing the method, it does not change. What to do here? Here is the code

void adding(MainC *MainCobj) { //2+1 ->3 if (MainCobj->n > MainCobj->m) k = n; else k = m; for (i = 0;i < k;i++) { MainCobj->c = MainCobj->a + MainCobj->b; } cout << "adding:" << c[1]<<endl; cout << "cc=" << MainCobj->c[1]<<endl;//cc= Это для проверки добавления } 
  • What is MainC ? Create a minimal example that reproduces the error, then perhaps you will be helped faster. - αλεχολυτ
  • MainC is the parent class. The error is that in the C array nothing changes after the execution of the method. Those. in the method ss = "Some value" and if you transfer an object to another method - in "C" is empty - Alex Alex
  • for (i = 0; i <k; i ++) {MainCobj-> c = MainCobj-> a + MainCobj-> b; } Did you remember to index by c? - free_ze
  • And yes, also: in this example, there is no OOP. There are classes like containers. But no OOP;) - Sergey Teplyakov

0