What is the function of the '->' in that line?

  • Thread starter Thread starter NCEE
  • Start date Start date
  • Tags Tags
    Function Line
AI Thread Summary
The '->' operator is used in C++ to access members of a class or structure through a pointer. In the example "pTerm = pid->pGain * error;", 'pid' is a pointer to a class or structure, and 'pGain' is a member of that class or structure. The expression 'pid->pGain' is functionally equivalent to dereferencing the pointer with '(*pid).pGain', but the '->' operator provides a cleaner syntax. This operator simplifies code readability and reduces the potential for errors when accessing member variables. Understanding the '->' operator is essential for working with pointers in C++.
NCEE
Messages
4
Reaction score
0
I was going through a bit of open source code when I came upon this line
"pTerm = pid->pGain * error;"

What is the function of the '->' in that line?
 
Engineering news on Phys.org
pid is a pointer to a class or structure.
pGain is a member of the class or structure.
pid -> pGain means the same as (*pid).pGain (but it looks prettier).
 
Very basic question. Consider a 3-terminal device with terminals say A,B,C. Kirchhoff Current Law (KCL) and Kirchhoff Voltage Law (KVL) establish two relationships between the 3 currents entering the terminals and the 3 terminal's voltage pairs respectively. So we have 2 equations in 6 unknowns. To proceed further we need two more (independent) equations in order to solve the circuit the 3-terminal device is connected to (basically one treats such a device as an unbalanced two-port...
suppose you have two capacitors with a 0.1 Farad value and 12 VDC rating. label these as A and B. label the terminals of each as 1 and 2. you also have a voltmeter with a 40 volt linear range for DC. you also have a 9 volt DC power supply fed by mains. you charge each capacitor to 9 volts with terminal 1 being - (negative) and terminal 2 being + (positive). you connect the voltmeter to terminal A2 and to terminal B1. does it read any voltage? can - of one capacitor discharge + of the...
Thread 'Weird near-field phenomenon I get in my EM simulation'
I recently made a basic simulation of wire antennas and I am not sure if the near field in my simulation is modeled correctly. One of the things that worry me is the fact that sometimes I see in my simulation "movements" in the near field that seems to be faster than the speed of wave propagation I defined (the speed of light in the simulation). Specifically I see "nodes" of low amplitude in the E field that are quickly "emitted" from the antenna and then slow down as they approach the far...
Back
Top