I have a question about the use variables by the files in different directory in c++.
I have a file a.h
class A
{
private:
B *b_;
}
in the file a.cpp, I included the a.h like this #include “a.h”
I have a other file b.h and b.cpp in the same folder as a.h and a.cpp
These is a other file called c.cpp, which is the same level as a.h and b.h,
class C
{
A *a_;
}
but the file d.h and d.cpp is in the subdirectory of a.h,b.h,c.h, like this: /(a.h)/(d.cpp, d.h), and in d.cpp, I already included a.h and b.h, but I use it like this way in d.cpp:
a_->b_;
it shows the following message:
warning: statement has no effect
how to fix this?
Th expression
a_->b_is just retrieving a value, but not doing anything with it, so as a statementa_->b_;, it is not much more useful than e.g.2;– you need to do something with it, e.g. assign that somewhere or give it as an argument to some function.If you don’t need an expression for its side effect or for its result, just remove it.