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

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
};

Related

error: enum class * is not a class or namespace [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 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.

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.)

c++ return type pointer declaration [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 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
function:
name: make_shape
return: Shape*
parameters: const string &shape_name; const vector &data
The class is ShapeFactory. This is what I have for this function definition:
ShapeFactory::Shape* make_shape(const string &shape_name, const vector<double>&data)
I get an error that says:
"ShapeFactory.cpp:17:15: error: ‘Shape’ in ‘class ShapeFactory’ does not name a type"
I know Shape* isn't a return type, but I don't know how to declare the pointer. Any suggestions?
You've written ShapeFactory::Shape* make_shape, which the compiler thinks is the implementation of a function in ShapeFactory called Shape*. You need to have the return type before this, and the bit after the :: is the function name. So, the correct code is:
Shape* ShapeFactory::make_shape(const string
&shape_name, const vector<double>&data)

Can't call a static function [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
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.
Improve this question
I declare in a header traductionCSV.h the function
static QVector<struct variableDurSupervision>
listVariableDurSupervison(std::string fichierCSV);
I write it in my cpp, then I want to use it in another file supervision.cpp, so I call it like this :
remplirDurCellule(
traductionCSV::listVariableDurSupervison(
"../../FichierCSV/ListeVariableSupervision.csv"
)
);
But it won't work, I got this error :
undefined reference to traductionCSV::listVariableDurSupervison(std::string)
I properly include all the file, so I don't understand.
Thank you.
You are probably missing the class name when you are defining it in cpp. It should be like :
QVector<struct variableDurSupervision> traductionCSV::listVariableDurSupervison(std::string fichierCSV)
{
...
}
This rule applies both to static and non-static functions of a class.

Error while compiling the code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I got a error message while compiling, saying that
node.h: In member function ‘void binary_tree::print(node*&, std::ofstream&)’:
node.h:17:10: error: ‘node* node::left_child’ is private
But in node.h, the member is public
class node {
public:
char *word;
int frequency;
node *left_child;
node *right_child; };
using MinGW for build and run. Pls help me in solving this issue.
You need to submit complete code for comments.
Error cannot occur if left_child is public. You can clean and rebuild your code.
binary_tree how is this class using class node?
it just worked well!!! but some kinda build error takes here. And this is the altered codes here - https://drive.google.com/file/d/0B5PwxyqEos-wb05vRzhvN21aYTQ/edit?usp=sharing