Absolute beginner question on scopes.

I have encountered a seemingly impassable obstacle right at the beginning. All I am trying to do is access a variable used in a script belonging to one object from the script of another object.
I thought I knew how to do that - by declaring the variable and within the class as well as the class itself as public and it should become accessible. I’ve always done that in C++ and Java (and even VB fwiw) but in Unity for some reason it seems not to work that way.

A specific example where I am failing:
I have a class named CursorBroadcast in a script of the same name attached to the DefaultCursor object.
I have another named FollowBall in a script of that name attached to an object, also named FollowBall. The object is just a sphere floating above the floor.

Now I want the FollowBall script to read the position of the cursor by reading a public variable maintained by the CursorBroadcast script or perhaps calling a method of that class, such as PosVec = CursorBroadcast.GetCursorPosition() or something of the sort.

The problem is that Visual Studio tells me that neither the function, nor the variable nor the class ‘exist in the current context’.

Now I know there a probably much better ways of getting the ball to act on input but that is beside the point at this stage. The real issue I have is the communication between scripts attached to different objects in a more general sense as without such a capability I think many things would become impossible.

I have been programming in Visual Basic, C, various assembly languages and a bit of C++ and Java for for the past 25 years or so, a lot of it on microcontrollers.
I think or rather thought I understood C++ well enough to get along but I am completely baffled by C# in Unity. I’m not sure how c# is different from c++ so I don;t know whether my difficulty is with c# or how it is used in Unity.

Thanks Hatsuko. I indeed did as you said and went through several more tutorials as well as the ones you suggested.

The way I got it to work was by declaring a public ‘GameObject’ in one script so it shows up in the Inspector and then drag/drop the other object into it. For now I will use that and then some time I will look at other ways of doing it as you mention there are.