Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ static method with struct parametrs

i have this problem...

i have a my struct:

typedef struct Mystruct{
  float a;
  float b;
}

and a static method:

float static MyStaticMethod(MyStruct a, MyStruct b);

when i call this method:

Mystruct s;
s.a = 1;
s.b = 2;

Mystruct t;
t.a = 1;
t.b = 2;

MyClass.MyStaticMethod(s,t);

i have this error at compile time:

Error   51  error C2228: left of '.MyStaticMethod' must have class/struct/union

Error   50  error C2275: 'MyClass' : illegal use of this type as an expression
like image 804
Safari Avatar asked Aug 21 '26 13:08

Safari


1 Answers

You need to call it using a scope resolution operator:

MyClass::MyStaticMethod(s,t);
       ^^
like image 164
Alok Save Avatar answered Aug 23 '26 04:08

Alok Save



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!