In C++ you can not access a non static class member from a static method. Make it a normal method and try like below:-
void getMessage(const sensor_msgs::Image::ConstPtr& recMmsg){ ROS_INFO( "I heard message" ); pub.publish(recMmsg); //*** ERROR IS HERE *** }
Else declare pub as static member
static ros::Publisher pub;
Also refer to the below answer
C++ static member functions and variables
Related Posts:
- Expression must have class type
- The static keyword and its various uses in C++
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Why is enum class preferred over plain enum?
- Why am I getting this redefinition of class error?
- Single class has a Class Redefinition Error
- C++ Linked List Node with class
- (->) arrow operator and (.) dot operator , class pointer
- Separating class code into a header and cpp file
- how to define -std=c++11 as default in g++
- Pointer to incomplete class type is not allowed
- Why am I getting this redefinition of class error?
- What is the difference between a static and const variable?
- no default constructor exists for class
- Static array vs. dynamic array in C++
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- What are the differences between struct and class in C++?
- error C2011: ” : ‘class’ type redefinition
- The compiler is complaining about my default parameters?
- C++ Linked List Node with class
- Getting error: ISO C++ forbids declaration of with no type
- “used without template parameters”
- expected constructor, destructor, or type conversion before ‘(’ token
- C++ Class ‘undeclared identifier”
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Base class undefined
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- What is the meaning of a C++ Wrapper Class?
- Does C++11 have C#-style properties?
- G++ undefined reference to class::function
- Creating an instance of class
- Don’t understand static boolean behavior
- error: ISO C++ forbids in-class initialization of non-const static member
- expected primary-expression before ‘]’ token
- error C2039: ‘string’ : is not a member of ‘std’, header file problem
- Does static constexpr variable inside a function make sense?
- istream and ostream problem – C++
- Why virtual & static keywords aren’t allowed outside class declaration?
- Struct with template variables in C++
- error: no member function declared in class
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- Error: invalid use of member in static member function
- Member function with static linkage
- Sleep for milliseconds
- C++ Cout & Cin & System “Ambiguous” [closed]
- Floating point exception( core dump
- undefined reference to `WinMain@16′
- How can I clear console
- How to go from fopen to fopen_s
- How does the modulus operator work?
- Identifier not found error on function call
- Debug assertion failed. C++ vector subscript out of range
- What causes a SIGABRT fault?
- invalid new-expression of abstract class type error
- How can I create objects while adding them into a vector?
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- Socket Programming in C++
- std::out_of_range error?
- Checking cin input stream produces an integer
- Where do “pure virtual function call” crashes come from?
- How to get current timestamp in milliseconds since 1970 just the way Java gets
- What is the best open XML parser for C++?
- *** No rule to make target ‘class.cpp’, needed by `build/….x86/class.o` Stop. error in Ubuntu
- What’s the difference between opening a file with ios::binary or ios::out or both?
- Hash function for a string
- CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
- How to run valgrind with basic c example?
- initial value of reference to non-const must be an lvalue
- Typedef function pointer?
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- cannot declare variable ‘’ to be of abstract type ‘’
- Strange error C2131: expression did not evaluate to a constant in VC 2015
- error: called object type ‘int’ is not a function or function pointer
- Hash function for a string
- Is there a replacement for unistd.h for Windows (Visual C)?
- How to call on a function found on another file?
- How to write std::string to file?
- Member declaration not found
- What is the difference between a .cpp file and a .h file?
- Stable Cotangent
- How to change string into QString?
- Including .cpp files
- Class template inheritance C++
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- What does ** mean in C++?
- Incomplete type is not allowed: stringstream
- Initializing default values in a struct
- Warning: comparison of distinct pointer types
- Two decimal places using printf( )
- error C2244 unable to match function definition to an existing declaration
- Initializing pointers in C++
- clearing a vector of pointers [duplicate]
- Evaluate a string with a switch in C++ [duplicate]
- C++ JSON Serialization
- stack around the variable…was corrupted
- Creating a list to hold objects in C++
- What does “warning: not all control paths return a value” mean? (C++)
- Array of Linked Lists C++
- Is it still safe to delete nullptr in c++0x?