I am having difficulty sing objects with the scope operator (::). I don't have any issues writing for (.) or (->) but I am doing something really ridiculous with (::).
In main, I create the class:
1 2 3 4 5 6 7
class Test
{
private:
public:
void print_it();
};
I left out the constructor and destruct or info and some of member variables to expedite.
1 2 3 4 5 6 7
void Test::print_it()
{
std::cout << "Test member scope" << std::endl;
}
Test test;
test::print_it();
I instantiate the Test class and try to call the function without luck. What am I doing wrong here?
Severity Code Description Project File Line Suppression State
Error C2510 'test': left of '::' must be a class/struct/union ArduCam_test c:\users\clang\desktop\working folder\opencv\xxxx_test\xxx_demo.cpp 58
-> is used to access a pointer-to-object's member function. It is equivalent to (*obj).member.
:: is used to access a static member of a class (and can also be used within the class member functions to disambiguate certain members, but don't worry about this yet.)
You want:
1 2
Test test;
test.print_it();
Here's a example to demonstrates the syntax (although doesn't do anything useful)