- Joined
- Jan 29, 2023
- Messages
- 6
- Reaction score
- 0
Hi, I am having a problem with declaring Struct Member Variables. What I want to do is create a Struct of Points in an x,y coordinate system wherein various bits of data related to the points are stored within the member variables of the Struct instances themselves. Here is an example of my code:
#include PointList.H
#include <cmath>
struct Point{
unsigned int x,y;
unsigned int IntValue(){
return x+y;
}
double YDivdedByX(){
return y/x;
}
double LRValue(){
return (y-((x+y)/2))
}
double OriginDistance(){
return sqrt((x*x)+(y*y))
}
double RadianValue(){
return asin((y / OriginDistance))
}
}
You might notice the OriginDistance value at the bottom. The problem with my code is that this seems to result in the member variables being treated as methods, not variables. I don't want to call methods from the struct, I want to access specific numeric values that are stored within instances of the struct. Can anyone help me with this?
#include PointList.H
#include <cmath>
struct Point{
unsigned int x,y;
unsigned int IntValue(){
return x+y;
}
double YDivdedByX(){
return y/x;
}
double LRValue(){
return (y-((x+y)/2))
}
double OriginDistance(){
return sqrt((x*x)+(y*y))
}
double RadianValue(){
return asin((y / OriginDistance))
}
}
You might notice the OriginDistance value at the bottom. The problem with my code is that this seems to result in the member variables being treated as methods, not variables. I don't want to call methods from the struct, I want to access specific numeric values that are stored within instances of the struct. Can anyone help me with this?