Can't call a static function [closed] - c++

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.

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

Variable not declared in the scope error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 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
Why am I getting this problem and how can I fix it? From my point of view I already declared it. Please see the image.
Thanks a lot!
You have an extra semicolon between the for statement and opening brace. That makes the for loop have an empty body, and the braced expressions have no idea what angle is supposed to be, since it truly is out-of-scope.

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)

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