error: enum class * is not a class or namespace [closed] - c++

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
enum class myEnum : short {
one = 11,
two = 22,
};
#define FOO(param) myEnum param() {return param;}
class testClass {
public:
FOO(myEnum::one)
};
https://godbolt.org/z/z1j3sP7eW
I'm not sure why the compiler is telling me myEnum is not a class. Different compilers are telling me different errors, too.

As the commenters pointed out, this error comes from the generated function name, myEnum::one() being invalid.

Related

Base class and templates [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
Can I write code like this (tried it and doesn't compile in VS2015):
template<class BaseClassT>
class DerivedClass : public BaseClassT
{
...
};
and then use it like:
class BaseClass
{
};
DeriveClass<BaseClass> c;
if not possible, is there a way to implement the same idea?
Yes, you may use a template argument as base, and it compiles in MSVS if you fix the typo.
(Note that this is not the CRTP, despite what you may have heard.)

error: expected ';', ',' or ') before numeric constant [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am making a stack class, and trying to make an object of it and using it in another class. However, it mentions that there is an error.
here's my code of intializing the stack object in the class:
class functions{
public:
int m[5];
int c=0;
stack_x mem(5);
You can't initialise members using parentheses in the class definition.
Use curly braces — stack_x mem{5};.
If the previous class (stack_x) looks like an custom class its correctly closed
class stack_x
{
// Class definition
}; // MUST BE
class functions
{
// Class definition
};

Can we push back struct containing vector without using constructor? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Lets say I have a struct:
struct group{
vector<int> a;
vector<int> b;
vector<int> c;
};
Then I create a vector of this struct:
std::vector<group> group_vec;
What I wanted was to do equivalent of
group obj;
obj.a.push_back(1);
obj.a.push_back(4);
obj.b.push_back(6);
obj.b.push_back(7);
group_vec.push_back(obj);
as
group_vec.push_back({{1,4},{6,7},{}}); // equivalent of above's object pushing
Yes, we can do
group_vec.push_back({{1,2},{2,3}});
We do use constructors in that statement, but I assume that you meant "without a user defined constructor".

compile error with boost hana define struct [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am starting with boost hana, and I am currently getting this compile problem while writing a basic program:
#include <boost/hana/define_struct.hpp>
namespace hana = boost::hana;
struct Foo
{
BOOST_HANA_DEFINE_STRUCT(Foo,
(int, var1_),
(double, var2),
);
};
I am using latest gcc compiler (6.1) and the compiler error that I get is
boost/hana/detail/struct_macros.hpp:2462:103: error:
‘BOOST_HANA_PP_DROP_BACK’ does not name a type
This is weird because when I looked at the headers, boost/hana/detail/preprocessor.hpp (a file included by the above struct_macros.hpp) does include this macro definition.
EDIT: Macros are horrible. :( Take a look at first answer.
It should be:
struct Foo
{
BOOST_HANA_DEFINE_STRUCT(Foo,
(int, var1_),
(double, var2) // no comma
);
};

C-style static array as a member of a template class - won't compile [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I was practising using C++ templates (sounds way better than "playing around") by coding something that would basically be my own implementation of std::array when I stumbled across an odd compilation failure. I reduced the problem into the following class, which fails to compile on gcc version 4.9.0:
template <typename TestType>
class TestClass
{
TestType[10] data;
};
What am I doing wrong here?
The array part of the type should go after the identifier:
TestType data[10];