Unfamiliar errors

In trying to solve some errors, I came across a couple on the msdn site that I don't understand what they are trying say (well several, but most of them are clearly using old c stuff I'm not familiar with such as this character not being used for math ^ but I'll stick with the reasonable ones)

The first is the c2352, illegal call of non static member function. I haven't made anything static and only some of my calls get this. I never had to declare functions as static before, but the msdn makes it sound like all my functions should be declared static like being not static is disallowed.

The next one is not so much about the error as the second to last example given (though I still can't figure out the error eithet) on the msdn site. c2660 (wrong number of arguments), the example shows this
int x = a[3][5] /c2660 error
int x = a[3, 5] // ok

I've never seen array use like this and tutorials don't even hint at it either. I suspect it isn't an array at all, but I don't know else it could be.

Last edited on
c2352, illegal call of non static member function
non-static means the function is not static.
member means it's a member function.

It's not complaining about these things. It's just giving you some information about the function that you are trying to call, that might be relevant.

The important part is where it says illegal call. It means you are doing something wrong when trying to call the function. Maybe you are trying to call the function without an object, that would explain why it informed you about the function being non-static because only static member functions can be called without an object.

int x = a[3, 5] // ok
The comma operator takes two arguments. First it evaluates the first argument and throws away the result, then it evaluates and returns the result of the second argument. So the result of 3, 5 is 5 so this code is really the same as writing simply:

 
int x = a[5]

https://en.wikipedia.org/wiki/Comma_operator
Considering that was posted as a solution to an error on msdn, I got the distinct impresson that it wasn't an array. Besides, they were considering a[3][5] to be an error and corrected with a[3,5]. Also the declaration was default [int, int] which certainly isn't normal either.
Derp, I meant to respond with this earlier,

I'll check again on the illegal calls, but nearly all the errors are in the function headers. That and some unhappy strings.
I think I found where you got the code from: https://msdn.microsoft.com/en-us/library/ek13fhc1.aspx#code-snippet-5

That code example is not standard C++. I think it's something called C++/CLI. Despite the name it is not the same language as C++.
Last edited on
Well, that is interesting. Thanks. I looked up c++/cli and actually got something.

Makes me want to just design my own language though.

Most of the errors were solved simply by renaming some of my functions including c2352. Weird if you ask me.
Topic archived. No new replies allowed.