Good evening!

Help to deal with the most ridiculous and stupid question: I have forms, parent and child, they can all interact with each other ....

#include "StdAfx.h" #include "Form1.h" #include "Form3.h" #include <iostream> #include <windows.h> #include <tchar.h> //================================ #define MAX_CLIENTS 64 int Count=0; namespace PA { bool testing(){//not form1 member ???????->richTextBox1->Text=""; //Не получается изменить или обратиться к переменной Form1 return 0; } void Form1::trdMethod(){ testing(); } void Form1::Form1(){} } 

There is a function that can access global variables (Count) in a cpp file ... And how can we get from it to any variable declared in the class of the parent window ??? Already how much was carried, and to no avail (

  • Many incomplete formulations. Show the code. - nitrocaster
  • Has corrected a question - Alerr

1 answer 1

Non-static members can only be accessed through an instance of the class. Pass this to the testing() function.

You will probably find it helpful to read the answers to this question .

  • And asli to address to the static? I am confounded by the lack of a class object of the main form (as if there is no object , but the form exists .... - Alerr
  • @Alerr, I wrote, pass this from Form1:trdMethod() to your function. - nitrocaster
  • This function is not mine. In general, it can not transmit anything ... - Alerr
  • Then what's your code? - nitrocaster
  • one
    Well, if it is impossible to get access to the form object in any way, it is impossible to get access to its fields. Look for how to access the form, without this in any way. - VladD