Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 3 years ago.
Improve this question
When I compile my files I get this warning :
In file included from AsyncSQL.cpp:8:0:
AsyncSQL.h: In constructor 'CAsyncSQL::CAsyncSQL()':
AsyncSQL.h:192:10: warning: 'CAsyncSQL::m_iCopiedQuery' will be initialized after [-Wreorder]
int m_iCopiedQuery;
^
Here is my AsyngSQL.H http://pastebin.com/u72kyuq7
So what am I doing wrong?
The problem is the order in which you initialize members in the initializer list on line 22,
_SQLResult(): pSQLResult(NULL), uiNumRows(0),
uiAffectedRows(0), uiInsertID(0)
These should appear in the same order as they appear in the class definition. For example:
class test {
test(): foo(1), bar(2) { }
int foo;
long bar;
};
Related
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 2 years ago.
Improve this question
game.h:
enum Game_state { MAIN_MENU, /*...*/ };
namespace list { class Linked_list { public: Linked_list() {} }; }
class Game {
public:
static Game_state state;
static list::Linked_list<Obj> objs;
};
Game_state Game::state = MAIN_MENU;
list::Linked_list<Obj> Game::objs = list::Linked_list<Obj>();
This gives me the linker error: multiple definition of Game::state (and Game::objs).
If I take out the type specifiers it gives me the compiler error: 'state' in 'class game' does not name a type (same for objs).
All I need is to initialize these members.
I'm using mingw on 32 bit windows 10.
You have to move those definitions into a translation unit (cpp file). Otherwise you will redefine them every time you include the header file somewhere, violating ODR.
Put the definitions of 'game::stat' and 'game::objs' in a *.cpp file and link against it.
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 4 years ago.
Improve this question
I have a file named: FeedbackCircuitVariables.h with the following inside:
#pragma once
struct FeedbackCircuitVariables {
// Unknown values (the ones which will be calculated).
float m_Ic, m_Ib;
float m_Vce;
// Known values (the ones asked to user through keyboard).
float m_Rc, m_Rb, m_Re;
float m_Vbe, m_Vcc;
};
And a class in FeedbackCircuit.h:
#pragma once
#include "FeedbackCircuitVariables.h"
class FeedbackCircuit {
private:
FeedbackCircuitVariables *m_pVariables;
public:
FeedbackCircuit(const FeedbackCircuitVariables *variables);
};
And this is the definition of that class:
#include "FeeedbackCircuit.h"
FeedbackCircuit(const FeedbackCircuitVariables *variables) {
}
But inside the header of the class the compiler says that FeedbackCircuitVariables isn't a type name.
What am I doing wrong?
Your constructor syntax is wrong.
Change:
FeedbackCircuit(const FeedbackCircuitVariables *variables)
To:
FeedbackCircuit::FeedbackCircuit(const FeedbackCircuitVariables *variables)
// ^^^^^^^^^^^^^^^^^ This is the scope of the thing you're defining.
Your code should build then.
You have to set the scope of FeedbackCircuit(const FeedbackCircuitVariables *variables) in FeedbackCircuit.cpp:
FeedbackCircuit::FeedbackCircuit(const FeedbackCircuitVariables *variables) {
}
Add FeedbackCircuit:: to tell the editor and compiler where the function is located.
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 5 years ago.
Improve this question
As far I understood the right place to put the default parameters is the declaration file (*.h). So for example:
test.cpp
void print_a(int a){
std::cout << a;
}
test.h
void print_a(int a = 5);
In this case I could have a third file. Where I can run print_a() with or without parameters.
main.cpp
#include test.h
int main(void)
{
print_a();
print_a(6);
return 0;
}
The problem is, what if inside test.cpp I have another function that wants to use print_a without parameters? The compiler tells me that the function has too few arguments.
How do you do it then ?
You need to provide the declaration of the function, with the default value, in test.cpp. The best way to do that is to #include test.h in test.cpp.
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 8 years ago.
Improve this question
I recently started to make a game with a friend, but we now encountered a problem with unsorted lists. I checked this site and other forums, but nothing seems to work.
Here's the code: http://pastebin.com/nx8sf6T2
And the compiler error: http://pastebin.com/fdQ7B0Dx
(And for compiling I use "clang++ -std=c++11 main3D.cpp", in case anyone is wondering)
hash<point> must be known at the time of instantiation of std::unordered_set<point>, and that requires point to be known before hash<point>:
struct point
{
// contents...
};
namespace std
{
template<>
struct hash<point>
{
// contents...
};
}
struct line
{
std::unordered_set<point> points;
// contents...
};
namespace std
{
template<>
struct hash<line>
{
// contents...
};
}
Demo
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 5 years ago.
Improve this question
I have a class, defined in a .h like this
#ifndef JLLABOUR_H
#define JLLABOUR_H
class JLLabour{
public:
JLLabour(int, int);
double* recursivefft(double*,int);
void FFT(int*);
~JLLabour();
private:
int width;
int height;
};
#endif // JLLABOUR_H
and in my .cpp I have the definition of my recursive function, the problem is that when I call it again , during compilation it doesnt allow me to continue because the method has not been defined yet. I dont know how to solve this, please help.
#include <JLLabour.h>
double* JLLabour::recursivefft(double* x,int asize){
//operations and declartions...
//...
even = recursiveFFT(sum,m); //<-- the problem is here, in the recursion.
odd = recursiveFFT(diff,m);
// more operations....
return result;
}
}
FYI I am compiling under Linux, using Qt because Im developing a graphic app...
C++ is case sensitive. Your method is called recursivefft not recursiveFFT.