Questions tagged [redefinition]
276 questions
171
votes
15 answers
C++ Redefinition Header Files (winsock2.h)
How do I prevent from including header files twice? The problem is I'm including the in MyClass.h and then I'm including MyClass.h in many files, so it includes multiple times and redefinition error occurs. How to prevent?
I'm using #pragma once…

akif
- 12,034
- 24
- 73
- 85
66
votes
4 answers
How to redefine a Ruby constant without warning?
I'm running some Ruby code which evals a Ruby file every time its date changes. In the file, I have constant definitions, like
Tau = 2 * Pi
and, of course, they make the interpreter display the unwanted "already initialized constant" warning every…

Eldritch Conundrum
- 8,452
- 6
- 42
- 50
31
votes
9 answers
Why am I getting this redefinition of class error?
Apologies for the code dump:
gameObject.cpp:
#include "gameObject.h"
class gameObject
{
private:
int x;
int y;
public:
gameObject()
{
x = 0;
y = 0;
}
gameObject(int inx, int iny)
{
x = inx;
…

Dataflashsabot
- 1,369
- 5
- 19
- 24
30
votes
5 answers
Override a member function with different return type
Consider the example below:
#include
using namespace std;
class base
{
public:
virtual int func()
{
cout << "vfunc in base class\n";
return 0;
}
};
class derived: public base
{
public:
…

nitin_cherian
- 6,405
- 21
- 76
- 127
28
votes
2 answers
Redefining or changing macro value
I am currently working on an already developed project written in MFC C++ and am facing a problem with an already present macro having the definition:
#define HEIGHT_TESTS 13
I am trying to change the value from within the code but I think since…

Neophile
- 5,660
- 14
- 61
- 107
15
votes
2 answers
Can't include
I'm using Visual Studio 2010.
I'm trying to write simple Camera class in OpenGL.
I need to include gl/gl.h in Camera.h
gl/gl.h is already included in main.cpp and Camera.h is included in main.cpp
When I put
#include
in Camera.h i got…

Ichibann
- 4,371
- 9
- 32
- 39
14
votes
3 answers
Ansible group vars priority
Let's say I have 3 files in group_vars:
abc.yml
all.yml
xyz.yml
And the same variable defined in them:
- my_var: abc
- my_var: all
- my_var: xyz
Ansible documentation says:
Within any section, redefining a var will overwrite the previous…

Nick Roz
- 3,918
- 2
- 36
- 57
13
votes
1 answer
error C2371: 'functionname' redefinition: different basic types
i have a Problem. I use Visual Studio 2013 and get the following Error:
Error C2371: 'getgrundflaeche' redefinition: different basic types.
I don't know why i get this Error. I get the same Error with VS12, when i try to call the function…

user2974830
- 428
- 1
- 4
- 13
12
votes
4 answers
Single class has a Class Redefinition Error
I'm new to C++, and I'm having a problem with my class definitions in a header file.
The code for the header file (Student.h) is:
#include
using namespace std;
class Student
{
// Data Members for a Student
string id;
string…

Mister R2
- 861
- 5
- 12
- 22
12
votes
10 answers
why do we actually have virtual functions?
I am new to C++.
Could anybody tell me the difference between method overriding and virtual function concepts in c++.
The functionality of virtual functions can be over-ridden in its derived classes.
Redefining a function in a derived class is…

Vijay
- 65,327
- 90
- 227
- 319
11
votes
3 answers
Redeclaration of global variable vs local variable
When I compile the code below
#include
int main()
{
int a;
int a = 10;
printf("a is %d \n",a);
return 0;
}
I get an error:
test3.c: In function ‘main’:
test3.c:6:5: error: redeclaration of ‘a’ with no linkage
test3.c:5:5: note:…

Jeegar Patel
- 26,264
- 51
- 149
- 222
11
votes
3 answers
PHP traits - change value of static property in inherited class
So, this is my trait:
trait Cacheable
{
protected static $isCacheEnabled = false;
protected static $cacheExpirationTime = null;
public static function isCacheEnabled()
{
return static::$isCacheEnabled && Cache::isEnabled();
…

morgoth84
- 1,070
- 2
- 11
- 25
10
votes
3 answers
Redefinition of class method in python
Context
I'm trying to have some "plugins" (I'm not sure this is the correct definition for this) to my code. By "plugin", I mean a module which defines a model (this is a scientific code) in such a way that its existence is enough to use it anywhere…

mhavel
- 735
- 1
- 7
- 19
10
votes
6 answers
error C2375: redefinition; different linkage
Error place in api:
#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT int CAnyseeUSBTVControllerDlg::InitCaptureDevice()
{
In my .h library class and function definition:
class CAnyseeUSBTVControllerDlg : public CDialog
{
//…

CarolusPl
- 639
- 4
- 9
- 18
10
votes
1 answer
Winsock redefinition errors
I am compiling a project in Visual C++ 2010, but I have problems with some Winsock redefinitions.
First of all I get:
syntax error : identifier 'SOCKADDR_STORAGE'
But if I include winsock or winsock2 or ws2tcpip i get many errors like these:
error…

Cooker
- 421
- 1
- 9
- 19