Tags down


C2011 'class' type redefinition

By : tissa
Date : July 29 2020, 10:00 AM
will be helpful for those in need Your file GBMap.cpp contains two definitions for the class GBMap. One you have written directly, and the other definition you have included from the file GBMap.h. After the inclusion, the translation unit looks like this:
code :
using namespace std;

class GBMap {


class GBMap {


Share : facebook icon twitter icon

C++/CLI: Public ref struct generates C2011: 'class' type redefinition

By : richieliuse
Date : March 29 2020, 07:55 AM
I hope this helps . You have to de-tune the traditional C/C++ header file think a bit when you work with managed code. The principal source of type declarations is the assembly metadata. This is very different from the native C/C++ compilation model where you have to have a header file for types that you make visible to other modules.
I'm going to guess that you get this C2011 error in the EXE project. Where you both added a reference to the DLL project assembly (like you should) and used #include on the header file. Like you should not. That's a guaranteed duplicate definition, #pragma once doesn't fix that.

Error C2011: 'XX' : 'class' type redefinition

By : Seth Cooper
Date : March 29 2020, 07:55 AM
this one helps. I have this compiler error (C2011) with this piece of code. I don't know what is wrong with it. , Include guards:
code :
#ifndef FILE_H
#define FILE_H

//file contents here

#pragma once

error C2011: '' : 'class' type redefinition

By : user2384271
Date : March 29 2020, 07:55 AM
To fix this issue One of the header files is as follows - , Change to code to something like this:
code :
#ifndef AAA_HEADER
#define AAA_HEADER

#include "stdafx.h"

class AAA
    std::string strX;
    std::string strY;


C2011 'Node':'class' type redefinition

By : user6509663
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Problem
In C++, headers are simply pasted into the body when you #include. So now the compiler sees:
code :
class Node {

   Node(int order) {};

// stuff from system headers omitted for brevity

using namespace std;

class Node {
  bool leaf;
 #include <map>

 using namespace std;

 class Node {
    bool leaf;
    Node** kids;
    map<int, string> value;
    int keyCount;//number of current keys in the node

    Node(int order);
Node::Node(int order) {
  // ...

Visual Studio 2015 C2011 'Class' type redefinition

By : crxticul
Date : March 29 2020, 07:55 AM
help you fix your problem Your .cpp files redefine your classes. You've already defined them in the respective .h files. All you need to include in your .cpp files is the implementations. They should look more like this:
code :
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <thread>

#include "numbers.h"
#include "loadingBar.h"

vector<string> fileReader::readTextFile(string path) {

    ifstream file(path.c_str(), ios::in | ios::binary | ios::ate);

    i = 0;
    size = 0;
    loadedBytes = 0;

    ifstream file(path.c_str(), ios::in | ios::binary | ios::ate);

    if (file.is_open()) {
        size = file.tellg();
        cout << "\t" << path << " (" << formatNumbers(size) << " bytes)" << endl;
        file.seekg(0, ios::beg);

        barThread = new std::thread(&loadingBar::run, *this);

        while (file >> line) {
            loadedBytes += strlen(line.c_str());

    else {
        cout << "Error reading : \"" << path << "\"" << endl;
    return list;

unsigned int fileReader::getSize() { return size; }
unsigned int fileReader::getLoadedBytes() { return loadedBytes; }
Related Posts Related Posts :
  • How can I store all data the user inputs and then show them if they want to see all of them
  • Use depth texture in compute shader
  • error: conflicting declaration using universal references
  • Using std::optional instead of own structure
  • Is it necessary to make pointer Null when there is no use of it at the end in c++
  • How are std::array's compared in C++?
  • Herb Sutter's article on making virtual functions private
  • Interaction between copy-and-swap idiom and move operations
  • Problems using overloaded extraction operator in C++
  • segmentation fault on reading certain files, seems to be unrelated to filesize
  • Protected members of base classes inaccessible to friends of derived classes
  • Constructing smart pointer from stack allocated raw pointer
  • Array Index Overload Bug
  • Why I'm getting " void value not ignored as it ought to be"?
  • Need help converting a string to a char in c++ ---- ERROR A value of type "const char *" cannot be used to ini
  • What means put preprocessor in std::string?
  • Is it possible to compare an array elements with a hard-coded initializer list without loop?
  • Complexity of an specific algorithm with 3 for?
  • Character converting funtion std::isupper() & std::islower() C++17
  • Hide method taking template parameter reference in cpp file
  • Disable the std::initializer_list constructor
  • What does "static_cast<double>(123)" mean in C++?
  • How to use libraries (*.a files) in C++ when using cmake
  • Use class name for conditional macro expansion
  • C++ variable names (can declare main as variable however same is not true for other functions name)
  • error: ‘nullptr’ was not declared in this scope
  • Why is the z coordinate flipped after multiplying with a matrix in GLSL - OpenGL
  • QML use C ++ function with parameters
  • How can I convert a character from a string into a integer variable using C++
  • Can range-v3 contains work on initializer list?
  • How would I calculate the runtime of this function?
  • Is there a way to produce random numbers simultaneously in c++? If not, is there a work around?
  • How do you create a dynamic array for struct elements of different variable types for c++?
  • Subclass address equal to virtual base class address?
  • _mm_xor_pd fails with product = 0
  • I got a stack overflow error in my int main()
  • Why does imwrite on BMP image gets stuck / does not return?
  • Why program throws runtime error while iterating over an emtpy vector in c++
  • Unknown error while debugging a QT-application with Visual Studio Code and CMake-Tools
  • Is `string.assign(string.data(), 5)` well-defined or UB?
  • Modern way to have a map that can point-to or reference data of different types that has been allocated on the stack
  • Why does my recursive function print in descending order and then in ascending order?
  • Fill vector with true value
  • Automate "yes" to Popen SSH command
  • warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
  • What is wrong in this C++ code snippet with template<class Vector>
  • Printing hollow square with array
  • Overload -> arrow operator in shared_ptr<interface> instance with no pure virtual destructor in interface
  • Run thread with derived method from base class without using templates
  • Issues with template class conversion - unable to deduce function called
  • How is memory deallocated in c++
  • is it possible to reduce delete code size with templates in C++
  • How to resolve Ninja c++ build and execution
  • Trying to control multithreaded access to array using std::atomic
  • Checking which object called the other's object method
  • How do we run a single test using Google bazel
  • Should I add other files to git except .cpp?
  • Idiom for handling size_t underflow in loop condition
  • What is Kotlin for C++ push_back() and pop_back() on a string?
  • Tree implementation in C++: Cannot convert Node to int* Ask Question
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org