<ar*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I'm using some lines of code like this:
ClassName *var = new ClassName(...);
and that's it. The class constructor does everything I want (there are
methods to do more but I don't need them)
But this generates a warning (gcc4) saying it's an unused variable.
Is there a better way to do this?
Even though g++ specific issues are off-topic here, I can come up with two
solutions:
int g_i = 0;
class ClassName
{
public:
ClassName(int i)
{
g_i += i; // everything I need
}
};
#include <iostream>
void do_it(ClassName const &)
{}
int main()
{
// one way
do_it(ClassName(1));
// another way
ClassName var(1) __attribute__((unused));
}
Ali