I saw this while browsing a C++ reference. I don't understand what myobject is when it's between the } and ;Code:struct myclass { bool operator() (int i,int j) { return (i<j);} } myobject;
This is a discussion on What does this mean? within the C++ Programming forums, part of the General Programming Boards category; Code: struct myclass { bool operator() (int i,int j) { return (i<j);} } myobject; I saw this while browsing a ...
I saw this while browsing a C++ reference. I don't understand what myobject is when it's between the } and ;Code:struct myclass { bool operator() (int i,int j) { return (i<j);} } myobject;
It defines an instance of class myclass with the name myobject.
It's the same as
Code:struct myclass { bool operator() (int i,int j) { return (i<j);} }; myclass myobject;
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
Err, right. My bad >_<
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
now it makes more sense!Code:struct { bool operator() (int i,int j) { return (i<j);} } isSmaller; int x=10, y=20; isSmaller(x, y);![]()
..which in the context of C++, thus a C++ struct, is the same as a class except that in structs all members default to public...rather an instance of struct myclass