Ошибка компилятора c3646

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Learn more about: Compiler Error C3646

Compiler Error C3646

06/14/2018

C3646

C3646

4391ead2-9637-4ca3-aeda-5a991b18d66d

Compiler Error C3646

‘specifier’ : unknown override specifier

Remarks

The compiler found a token in the position where it expected to find an override specifier, but the token was not recognized by the compiler.

For example, if the unrecognized specifier is _NOEXCEPT, replace it with the keyword noexcept.

For more information, see Override Specifiers.

Example

The following sample generates C3646 and shows a way to fix it:

// C3646.cpp
// compile with: /clr /c
ref class C {
   void f() unknown;   // C3646
   // try the following line instead
   // virtual void f() abstract;
};

I modified my project and after compiling there pop up some weird error.

#ifndef BART_RAY_TRACER_MESH_H
#define BART_RAY_TRACER_MESH_H

#include <vector>
#include "assert.h"
#include "vec3f.h"

class Triangle;

class Mesh {
public:
    uint32_t nverts;
    bool _is_static;
    vec3f *verts;
    vec3f *_verts_world;
    Material material; 
    // 2 error occurs at the line below
    Matrix4x4 _trans_local_to_world; // '_trans_local_to_world': unknown override specifier & missing type specifier - int assumed. Note: C++ does not support default-int
    Matrix4x4 _trans_local_to_world_inv;
    TransformHierarchy *_trans_hierarchy;   

    std::vector<Triangle* > triangles;
    // ...
};
#endif

When I change the order of the declaration a little bit, the error always occurs the line after Material material, but with different message:

#ifndef BART_RAY_TRACER_MESH_H
#define BART_RAY_TRACER_MESH_H

#include <vector>
#include "assert.h"
#include "vec3f.h"

class Triangle;

class Mesh {
public:
    uint32_t nverts;
    bool _is_static;
    vec3f *verts;
    vec3f *_verts_world;
    Material material; 
    // 2 error occurs at the line below
    TransformHierarchy *_trans_hierarchy; // error C2143: syntax error: missing ';' before '*' & error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    Matrix4x4 _trans_local_to_world;
    Matrix4x4 _trans_local_to_world_inv;  

    std::vector<Triangle* > triangles;
    // ...
};
#endif

I’ve searched for similar questions on SO but none seems useful.
I’ve checked my vec3f, Triangle class definition in case there are missing semicolons but I can’t find any.

Can any one help?

asked Sep 13, 2017 at 3:18

jinglei's user avatar

jingleijinglei

3,23911 gold badges27 silver badges46 bronze badges

5

This is just another Microsoft cock-up. Here it is in essence:

class C
  {
  x y ;
  } ;

If you submit this to a sensible compiler like g++, it gives you a helpful error message:

3:2: error: ‘x’ does not name a type

MSVC, on the other hand, comes up with this gibberish:

(3): error C3646: ‘y’: unknown override specifier
(3): error C4430: missing type specifier — int assumed. Note: C++ does not
support default-int

With this key, you can decrypt Microsoft’s error message into:

error: ‘Matrix4x4’ does not name a type

answered Oct 26, 2019 at 14:19

TonyK's user avatar

TonyKTonyK

16.6k4 gold badges36 silver badges71 bronze badges

The error is most likely because that TransformHierarchy and Matrix4x4 are not defined.

If they are not defined in "assert.h" and "vec3f.h", this should be the case.

Forward declaration is enough only when you use the reference types and/or pointer types only. Therefore, to forward declare Triangle is OK. But forward declare Triangle does not mean your shape.h is processed. Neither does your material.h which is included in shape.h.

Therefore, all names in material.h is not visible from this code.
TransformHierarchy and Matrix4x4 are not recognized by the compiler.
Many of the compliers will complain with words similar to "missing type specifier - int assumed"

answered Sep 13, 2017 at 4:17

doraemon's user avatar

doraemondoraemon

2,2781 gold badge17 silver badges35 bronze badges

In my case, it was found that a header file had the following directives for a class [ie, myComboBoxData]

#ifndef __COMBOBOXDATA__
#define __COMBOBOXDATA__
// ... 
class myComboBoxData
{
    // ...
}
#endif

As another class below tried to use myComboBoxData class

class TypeDlg : public CDialog
{
    myComboBoxData cbRow,cbCol;
    // ...
}

the error message popped up as above:

«error C3646: ‘cbRow’: unknown override specifier».

Solution:

The problem was the directive name (__COMBOBOXDATA__) was already used by OTHER header.

Thus, make sure to use some other name like (__myCOMBOBOXDATA__).

answered May 31, 2020 at 5:56

Meung Kim's user avatar

I got the following error:

error C3646: 'closure' : unknown override specifier

The code:

void BaseOperator::mousebutton_cb(EventObject* sender, EventArgs* calldata, void* closure)
{
    xd3D::Operation::Operator::BaseOperator* operator = (xd3D::Operation::Operator::BaseOperator*)closure;
    MouseButtonEventArgs* e = (MouseButtonEventArgs*)calldata;
    if (e->Status == Down)
        operator->OnMouseButtonDown(e);
    else
        operator->OnMouseButtonUp(e);
}

Do you know why I have this error?

Mateen Ulhaq's user avatar

Mateen Ulhaq

23.9k18 gold badges95 silver badges132 bronze badges

asked Dec 13, 2010 at 8:22

Spectral's user avatar

1

operator is a keyword. The sequence operator = tries to declare an assignment operator which in your case would have a pointer parameter type. And your compiler wants to parse the very last closure as a special specifier like override (afaik an extension of MSVC), const or such.

Rename the variable to something else, like myoperator.

answered Dec 13, 2010 at 8:27

Johannes Schaub - litb's user avatar

1

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once
 
#include <iostream>
#include <string>
 
using namespace std;
 
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
 
class Square
{
protected:
    string text;    int x;
    int y;
    int width;
    int height;
public:
    virtual void Print() = 0;
};

Добавлено через 2 минуты

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
 
#include <Windows.h>
#include "Square.h"
#include "WindowVector.h"
 
class WindowVector;
 
class Window : public Square
{
public:
    Window(int, int, int);
    Window(const Window&);
    Window& operator=(const Window&);
    void change(int, int, int);
    void Delete();
    void Print();
    friend WindowVector;
};
 
Window::Window(int x, int y, int count)
{
    text = "New window";
    text += ' ';
    text += (count + '0'); // преобразовываем int в char
    this->x = x;
    this->y = y;
    width = 30;
    height = 11;
}
 
Window::Window(const Window &obj)
{
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
}
 
Window& Window::operator=(const Window &obj)
{
    if (this == &obj)
        return *this;
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
    return *this;
}
 
void Window::change(int x, int y, int count)
{
    text = "New window";
    text += ' ';
    text += (count + '0');
    this->x = x;
    this->y = y;
    width = 30;
    height = 11;
}
 
void Window::Delete()
{
    this->~Window();
}
 
void Window::Print()
{
    COORD c = { x, y };
    DWORD d;
 
    SetConsoleCursorPosition(hOut, c);
    SetConsoleTextAttribute(hOut, 0x17);
    for (int i = 0; i <= width; ++i)
    {
        if (i == width)
            cout << 'X';
        else if (i < text.size())
            cout << text[i];
        else
            cout << ' ';
    }
    SetConsoleTextAttribute(hOut, 0x88);
    for (int i = 1; i <= height; ++i)
    {
        c.X = x;
        c.Y = y + i;
 
        FillConsoleOutputAttribute(hOut, 0xff, width + 1, c, &d);
        FillConsoleOutputCharacter(hOut, ' ', width + 1, c, &d);
        c.X = x + width + 1;
        SetConsoleCursorPosition(hOut, c);
        cout << ' ';
    }
    c.X = x + 1;
    c.Y = y + height + 1;
    FillConsoleOutputAttribute(hOut, 0x80, width + 1, c, &d);
    FillConsoleOutputCharacter(hOut, ' ', width + 1, c, &d);
    SetConsoleTextAttribute(hOut, 0x0);
}

Добавлено через 21 секунду

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#pragma once
 
#include <Windows.h>
#include "Square.h"
#include "WindowVector.h"
 
class WindowVector;
 
class CloseButton : public Square
{
public:
    CloseButton();
    CloseButton(string, int, int, int, int);
    CloseButton(const CloseButton&);
    CloseButton& operator=(const CloseButton&);
    void Delete();
    void Print();
    friend WindowVector;
};
 
CloseButton::CloseButton()
{
    text = "CLOSE";
    x = 0 + 19;
    y = 0 + 9;
    width = 6;
    height = 3;
}
 
CloseButton::CloseButton(string header, int x, int y, int width, int height)
{
    text = header;
    this->x = x;
    this->y = y;
    this->width = width;
    this->height = height;
}
 
CloseButton::CloseButton(const CloseButton &obj)
{
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
}
 
CloseButton& CloseButton::operator=(const CloseButton &obj)
{
    if (this == &obj)
        return *this;
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
    return *this;
}
 
void CloseButton::Delete()
{
    this->~CloseButton();
}
 
void CloseButton::Print()
{
    COORD c = { x, y };
 
    SetConsoleCursorPosition(hOut, c);
    SetConsoleTextAttribute(hOut, 0x80);
    for (int i = 0; i <= width; ++i)
    {
        if (i == 0)
            cout << ' ';
        else if (i <= text.size())
            cout << text[i - 1];
        else
            cout << ' ';
    }
    SetConsoleTextAttribute(hOut, 0x0); 
}
 
class CheckButton : public Square
{
public:
    CheckButton();
    CheckButton(string, int, int, int, int);
    CheckButton(const CheckButton&);
    CheckButton& operator=(const CheckButton&);
    void Delete();
    void Print();
    friend WindowVector;
};
 
CheckButton::CheckButton()
{
    text = "CHECK";
    x = 0 + 4;
    y = 0 + 9;
    width = 6;
    height = 3;
}
 
CheckButton::CheckButton(string header, int x, int y, int width, int height)
{
    text = header;
    this->x = x;
    this->y = y;
    this->width = width;
    this->height = height;
}
 
CheckButton::CheckButton(const CheckButton &obj)
{
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
}
 
CheckButton& CheckButton::operator=(const CheckButton &obj)
{
    if (this == &obj)
        return *this;
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
    return *this;
}
 
void CheckButton::Delete()
{
    this->~CheckButton();
}
 
void CheckButton::Print()
{
    COORD c = { x, y };
 
    SetConsoleCursorPosition(hOut, c);
    SetConsoleTextAttribute(hOut, 0x80);
    for (int i = 0; i <= width; ++i)
    {
        if (i == 0)
            cout << ' ';
        else if (i <= text.size())
            cout << text[i - 1];
        else
            cout << ' ';
    }
    SetConsoleTextAttribute(hOut, 0x0);
}

Добавлено через 16 секунд

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
 
#include <Windows.h>
#include "Square.h"
#include "WindowVector.h"
 
class WindowVector;
 
class Field : public Square
{
public:
    Field();
    Field(string, int, int, int, int);
    Field(const Field&);
    Field& operator=(const Field&);
    void Delete();
    void Print();
    friend WindowVector;
};
 
Field::Field()
{
    text.clear();
    x = 0 + 2;
    y = 0 + 2;
    width = 28;
    height = 5;
}
 
Field::Field(string header, int x, int y, int width, int height)
{
    text = header;
    this->x = x;
    this->y = y;
    this->width = width;
    this->height = height;
}
 
Field::Field(const Field &obj)
{
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
}
 
Field& Field::operator=(const Field &obj)
{
    if (this == &obj)
        return *this;
    text = obj.text;
    x = obj.x;
    y = obj.y;
    width = obj.width;
    height = obj.height;
    return *this;
}
 
void Field::Delete()
{
    this->~Field();
}
 
void Field::Print()
{
    COORD c = { x, y };
    DWORD d;
 
    SetConsoleCursorPosition(hOut, c);
    SetConsoleTextAttribute(hOut, 0x99);
    for (int i = 0; i <= height; ++i)
    {
        c.X = x;
        c.Y = y + i;
        FillConsoleOutputAttribute(hOut, 0x99, width - 1, c, &d);
        FillConsoleOutputCharacter(hOut, ' ', width - 1, c, &d);
        cout << ' ';
    }
    SetConsoleTextAttribute(hOut, 0x0);
}



0



Я пытаюсь написать простой движок DirectX11, но продолжаю получать эту странную ошибку и не могу найти проблему: я определяю класс Terrain и класс Mesh и #include класс Mesh в классе Terrain:

определение класса Terrain:

// Terrain.h
#pragma once

#include "Noise.h"#include "Mesh.h"
class Terrain
{
public:
Terrain(float width, float depth, int numVerticesW, int numVerticesD);
~Terrain();
float GetHeight(float x, float z);
void Draw();
private:
Mesh mMesh;                     // I get the error on this line
Noise mNoiseGenerator;
std::vector<float> mHeights;
void CreateTerrain(float width, float depth, int numVerticesW, int numVerticesD);
float ComputeHeight(float x, float z, float startFrequency, float startAmplitude, float persistence, int octaves);
};

и определение класса Mesh:

// Mesh.h
#pragma once

#include <d3d11.h>
#include <vector>
#include "Game.h"
class Mesh
{
public:
Mesh();
~Mesh();
template <typename T, unsigned int N>
void LoadVertexBuffer(T data[][N], unsigned int size, bool dynamic = false);
void LoadIndexBuffer(std::vector<unsigned int> indices);
void SetVertexCount(unsigned int vertexCount);
void Bind();
void Draw();
private:
std::vector<ID3D11Buffer*> mVertexBuffers;
std::vector<unsigned int> mStrides;
ID3D11Buffer *mIndexBuffer;
unsigned int mVertexCount;
};template <typename T, unsigned int N>
void Mesh::LoadVertexBuffer(T data[][N], unsigned int size, bool dynamic)
{
D3D11_BUFFER_DESC bufferDesc = {};
bufferDesc.Usage = dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_IMMUTABLE;
bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bufferDesc.ByteWidth = sizeof(T[N]) * size;
bufferDesc.CPUAccessFlags = dynamic ? D3D11_CPU_ACCESS_WRITE : 0;
bufferDesc.MiscFlags = 0;
bufferDesc.StructureByteStride = 0;

D3D11_SUBRESOURCE_DATA bufferData = {};
bufferData.pSysMem = data;

ID3D11Buffer *buffer;
Game::GetInstance()->GetDevice()->CreateBuffer(&bufferDesc, &bufferData, &buffer);
mVertexBuffers.push_back(buffer);
mStrides.push_back(sizeof(T[N]));
}

Когда я компилирую код, я получаю:

Severity    Code    Description Project File    Line    Suppression State
Error   C3646   'mMesh': unknown override specifier DirectX11 engine 0.3    c:userslucadesktopprogrammingcodec++sourcevisual studiodirectx11 engine 0.3terrain.h  14
Severity    Code    Description Project File    Line    Suppression State
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    DirectX11 engine 0.3    c:userslucadesktopprogrammingcodec++sourcevisual studiodirectx11 engine 0.3terrain.h  14

Я искал в Интернете, но большинство результатов показывают пропущенные точки с запятой или циклические проблемы с включением, но я не могу их найти.

РЕДАКТИРОВАТЬ
Я обнаружил проблему, но не могу объяснить, почему мое решение работает:
следуя дереву включения:
Terrain.h -> Mesh.h -> Game.h -> Renderer.h -> Terrain.h

устранение #include «Terrain.h» (поскольку я просто объявляю указатели Terrain * внутри класса) и добавление его в Terrain.cpp, похоже, решает проблему.
Так что, должно быть, речь идет о круговом включении, но разве я не должен быть защищен от этого с помощью защиты заголовка / включения?

1

Решение

Ваша проблема в том, что #pragma once предотвращает только двойное включение. То есть это делает следующее безопасным (упрощенным, чтобы сделать это очевидным):

// Terrain.cpp
#include "Terrain.h"#include "Terrain.h"

Это не решает круговое включение, которое гораздо сложнее решить автоматически. С двойным включением понятно, кто из них первый. Но у круга нет начала.

2

Другие решения

Других решений пока нет …

I have been migrating the VC6 project into VS2010 compiler. Project compiles good with VC6 version but not VS2010. Here is the code snippet. Any help or guidance would be really appreciated.

grdictrl.h

class CTndGXDICtrl : public CGXEditControl
{
int DECLARE_CONTROL(CTndGXDICtrl);

// Construction
public:
CTndGXDICtrl(CGXGridCore* pGrid, UINT nID, DWORD dwContext);
DECLARE_DYNAMIC(CTndGXDICtrl)

// Attributes
public:
CDataItemRef*
GetDataItemRef(int nRow, int nCol);
CDataEntity::deType GetTargetType(int nRow, int nCol);
DWORD GetContext(int nRow, int nCol);
void SetContext(int nRow, int nCol, CProject* pProj, DWORD dwContext);
CProject*
GetProject(int nRow, int nCol);
void SetTargetType(int nRow, int nCol, CDataEntity::deType eType);
void EmptyDataItemRef(int nRow, int nCol);
void Empty(int nRow, int nCol);
BOOL IsDataModified(int nRow, int nCol);
void SetDataModified(int nRow, int nCol, BOOL b);
// Operations
public:
//
// Returns true if the edit control is in the state to find an array index
//
BOOL CTndGXDICtrl::CanFindArrayIndex();

//
// Update a local/param entry — a CLocal/CParam
//
BOOL UpdateLocalParamEntry(CDataEntity* pDE);

//
// right mouse menu for Find and Instant XRef
//
void LoadRightMouseMenu(CPoint point, BOOL bEnableLocal);

BOOL ParseAndAssignDataItemRef(ROWCOL row, ROWCOL col, const CString& cs);
BOOL ParseAndAssignDataItemRef(const CString& cs);

// Overrides

// CGXControl interface
virtual BOOL OnValidate(ROWCOL row, ROWCOL col, const CString& s);
virtual BOOL OnValidate();
virtual BOOL OnLeftCell(ROWCOL nNewRow, ROWCOL nNewCol);
virtual BOOL OnGridChar(UINT nChar, UINT nRepCnt, UINT nFlags);
virtual BOOL LButtonDblClk(UINT nFlags, CPoint point);

virtual BOOL ValidatePaste(const CString& sPaste);
virtual BOOL SetControlText(ROWCOL nRow, ROWCOL nCol, const CString& str, UINT nFlags, const CGXStyle* pOldStyle);

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTndGXDICtrl)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CTndGXDICtrl();

private:
void GetAllOidsForXref(CDWordArray& arrOids);

// Generated message map functions
protected:
//{{AFX_MSG(CTndGXDICtrl)
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT flags);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRmouseFindGlobalDi();
afx_msg void OnRmouseFindLocalDi();
afx_msg void OnRmouseInstantXref();
//}}AFX_MSG
LRESULT OnPostedReturnDataItem(WPARAM, LPARAM);

DECLARE_MESSAGE_MAP()

BOOL m_bInOnChange;
BOOL m_bAutoComplete;
BOOL m_bIgnoreKillFocusForFind;

BOOL DoAutoComplete();
CDIControlInfo* GetDIC(int nRow, int nCol);

};

gridctrl.cpp

#include «stdafx.h»

#include «dbg.h»
#include «dbifexp.h»
#include «gridctrl.h»
#include «launch.h»
#include «tagparse.h»
#include «tndmsgs.h»
#include «resource.h»

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

#import «..binpb.tlb» named_guids //raw_interfaces_only

IMPLEMENT_CONTROL(CTndGXDICtrl, CGXEditControl)
IMPLEMENT_DYNAMIC(CTndGXDICtrl, CGXEditControl)

#define GRID_WARNING(IDP)
{
CString cs;

VERIFY(cs.LoadString(IDP));

Grid()->SetWarningText(cs);

}

/////////////////////////////////////////////////////////////////////////////
// CTndGXDICtrl

CTndGXDICtrl::CTndGXDICtrl(CGXGridCore* pGrid, UINT nID, DWORD dwContext)
: CGXEditControl(pGrid, nID)
{
m_bInOnChange = FALSE;
m_bAutoComplete = TRUE;
m_bIgnoreKillFocusForFind = FALSE;
}

CTndGXDICtrl::~CTndGXDICtrl()
{
}

BEGIN_MESSAGE_MAP(CTndGXDICtrl, CGXEditControl)
//{{AFX_MSG_MAP(CTndGXDICtrl)
ON_WM_CHAR()
ON_WM_LBUTTONDBLCLK()
ON_COMMAND(ID_RMOUSE_FIND_GLOBAL_DI, OnRmouseFindGlobalDi)
ON_COMMAND(ID_RMOUSE_FIND_LOCAL_DI, OnRmouseFindLocalDi)
ON_COMMAND(ID_RMOUSE_INSTANT_XREF, OnRmouseInstantXref)
//}}AFX_MSG_MAP
ON_MESSAGE(TND_RETURNED_DATAITEM, OnPostedReturnDataItem)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTndGXDICtrl message handlers
void CTndGXDICtrl::EmptyDataItemRef(int nRow, int nCol)
{
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
CDataItemRef* pDIR = NULL;
pDIR = &(pDIC ->m_cDataItemRef);
pDIR ->Empty();
}
}

void CTndGXDICtrl::Empty(int nRow, int nCol)
{
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
CDataItemRef* pDIR = NULL;
pDIR = &(pDIC ->m_cDataItemRef);
pDIR ->Empty();
SetTargetType(nRow, nCol, CDataEntity::deNull);
}
}
CDIControlInfo* CTndGXDICtrl::GetDIC(int nRow, int nCol)
{
if ((nRow == -1) || (nCol == -1))
return NULL;
CDIControlInfo* pDIC = NULL;
CGXGridWnd* pGrid = (CGXGridWnd*) GridWnd();
if (NULL != pGrid)
{
CGXStyle s;
pGrid ->GetStyleRowCol(nRow, nCol, s);
pDIC = (CDIControlInfo*) s.GetItemDataPtr();
}
return pDIC;
}

CDataItemRef* CTndGXDICtrl::GetDataItemRef(int nRow, int nCol)
{
CDataItemRef* pDIR = NULL;
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
pDIR = &(pDIC ->m_cDataItemRef);
}
return pDIR;
}

CDataEntity::deType CTndGXDICtrl::GetTargetType(int nRow, int nCol)
{
CDataEntity::deType eType = CDataEntity::deNull;
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
eType = pDIC ->m_eTargetType;
}
return eType;
}

DWORD CTndGXDICtrl::GetContext(int nRow, int nCol)
{
DWORD dw = 0;
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
dw = pDIC ->m_dwContext;
}
return dw;
}

CProject* CTndGXDICtrl::GetProject(int nRow, int nCol)
{
CProject* p = NULL;
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
p = pDIC ->m_pProject;
}
return p;
}

void CTndGXDICtrl::SetContext(int nRow, int nCol, CProject* pProj, DWORD dwContext)
{
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
pDIC ->m_dwContext = dwContext;
}
}

void CTndGXDICtrl::SetTargetType(int nRow, int nCol, CDataEntity::deType eType)
{
CDIControlInfo* pDIC = GetDIC(nRow, nCol);
if (NULL != pDIC)
{
pDIC ->m_eTargetType = eType;
}
}

Here is the complete error list:

c:2010fv32gridctrl.cpp(41): error C3646: ‘CRuntimeClass’ : unknown override specifier
c:2010fv32gridctrl.cpp(41): error C2143: syntax error : missing ‘;’ before ‘*’
c:2010fv32gridctrl.cpp(41): error C4430: missing type specifier — int assumed. Note: C++ does not support default-int
c:2010fv32gridctrl.cpp(41): error C2509: ‘_GetBaseClass’ : member function not declared in ‘CTndGXDICtrl’
          c:2010fv32gridctrl.h(58) : see declaration of ‘CTndGXDICtrl’

Error C3646 shows up with the following line:

IMPLEMENT_DYNAMIC(CTndGXDICtrl, CGXEditControl)

I may be missing something here, any guidance will be useful.

Regards.

Учу C++ по книге, в конце главы есть задания и одно из них — сделать функцию подсчета символов в классе Document. При создании класса возникла проблема: при запуске программы появляется ошибка «C3646 begin: неизвестный спецификатор определения». Такая же ошибка с функцией end();

document.h:

#include <list>
#include <vector>
#include <iostream>
using namespace std;

using Line = vector<char>;

struct Document {
    list<Line> line;
    Document() { line.push_back(Line{}); }

    Text_iterator begin() { return Text_iterator(line.begin(), line.begin()->begin()); } //здесь ошибка
    Text_iterator end() { return Text_iterator(line.end(), line.end()->end()); } //в этой строке так же

    int count();
};

istream& operator>> (istream& is, Document& d) {
    for (char ch; is.get(ch);) {
        d.line.back().push_back(ch);
        if (ch == 'n') d.line.push_back(Line{});

    }

    if (d.line.back().size()) d.line.push_back(Line{});

    return is;
}

class Text_iterator {
    list<Line>::iterator ln;
    Line::iterator pos;

public:
    Text_iterator (list<Line>::iterator ll, Line::iterator pp) : ln{ll}, pos{pp} {}
    char& operator* () { return *pos;  }

    Text_iterator& operator++ ();

    bool operator== (const Text_iterator& other) const { return ln == other.ln && pos == other.pos; }
    bool operator!= (const Text_iterator& other) const { return !(*this == other); }
};

Понравилась статья? Поделить с друзьями:
  • Ошибка компилятора c2995
  • Ошибка компиляции для платы arduino uno grbl
  • Ошибка компилятора c2784
  • Ошибка компиляции для платы arduino nano что делать
  • Ошибка компилятора c2731