|
You last visited: Today at 15:42
Advertisement
C++ Class Definitions
Discussion on C++ Class Definitions within the C/C++ forum part of the Coders Den category.
04/04/2014, 11:28
|
#1
|
elite*gold: 0
Join Date: Jul 2011
Posts: 331
Received Thanks: 65
|
C++ Class Definitions
Hallo,
ich sitzt vor nem Fehler und komm einfach nicht weiter. Mittlerweile denke ich schon fast, dass es am Compiler liegt
Hier sind 3 Versuche mit Errors:
Versuch 1:
Code:
Code:
class CConsignmentMng
{
private:
map<DWORD,char> m_mapItems;
CConsignmentMng();
~CConsignmentMng();
public:
static CConsignmentMng *Instance();
public bool IsBuyable(DWORD dwSEQ);
public void BuyItem(DWORD dwSEQ);
public void RemoveItem(DWORD dwSEQ);
public void AddItem(DWORD dwSEQ, char cState = 'O');
}
Error:
Quote:
error C2144: syntax error : 'bool' should be preceded by ':'
error C2144: syntax error : 'void' should be preceded by ':'
error C2144: syntax error : 'void' should be preceded by ':'
error C2144: syntax error : 'void' should be preceded by ':'
|
Versuch 2:
Code:
Code:
class CConsignmentMng
{
private:
map<DWORD,char> m_mapItems;
CConsignmentMng();
~CConsignmentMng();
public:
static CConsignmentMng *Instance();
bool IsBuyable(DWORD dwSEQ);
void BuyItem(DWORD dwSEQ);
void RemoveItem(DWORD dwSEQ);
void AddItem(DWORD dwSEQ, char cState = 'O');
}
Error:
Quote:
|
error C2533: 'CConsignmentMng::__ctor' : constructors not allowed a return type
|
==>
Code:
CConsignmentMng::CConsignmentMng()
{
m_mapItems.clear();
}
Versuch 3:
Code:
Code:
class CConsignmentMng
{
private:
map<DWORD,char> m_mapItems;
CConsignmentMng();
~CConsignmentMng();
public:
static CConsignmentMng *Instance();
bool IsBuyable(DWORD dwSEQ);
void BuyItem(DWORD dwSEQ);
void RemoveItem(DWORD dwSEQ);
void AddItem(DWORD dwSEQ, char cState = 'O');
};
Error:
Quote:
error C2653: 'CConsignmentMng' : is not a class or namespace name
error C2227: left of '->AddItem' must point to class/struct/union
type is ''unknown-type''
//...
|
Was mach ich falsch?
mfg lolxdfly
|
|
|
04/04/2014, 12:07
|
#2
|
elite*gold: 1765
Join Date: Aug 2011
Posts: 2,538
Received Thanks: 400
|
1. Versuch: Entferne die ganzen publics vor den Methodendeklarationen, die stehen ja schon im Publicbereich.
Alternative(wenn auch unnötig): hinter jedes public ein ":"
Edit: Vergiss meinen Beitrag, hab mir die anderen Versuche nicht angeschaut...
|
|
|
04/04/2014, 12:20
|
#3
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
hast die memberdefinitionen i-wo vor der deklaration oder vergessen den header in der cpp einzubinden.
|
|
|
04/04/2014, 12:36
|
#4
|
elite*gold: 0
Join Date: Jul 2011
Posts: 331
Received Thanks: 65
|
Quote:
Originally Posted by Dr. Coxxy
hast die memberdefinitionen i-wo vor der deklaration oder vergessen den header in der cpp einzubinden.
|
der Header ist in der Cpp drinne!
Was genau meinst du mit
Quote:
Originally Posted by Dr. Coxxy
hast die memberdefinitionen i-wo vor der deklaration
|
|
|
|
04/04/2014, 12:40
|
#5
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
bei versuch 3:
error C2653: 'CConsignmentMng' : is not a class or namespace name
error C2227: left of '->AddItem' must point to class/struct/union
er kennt offensichtlich an der stelle wo du CConsignmentMng->AddItem definierst noch nicht die CConsignmentMng klasse.
außerdem sollte man afaik bei nem singleton den destruktor public machen und noch den = operator private überladen.
|
|
|
04/04/2014, 12:47
|
#6
|
elite*gold: 0
Join Date: Oct 2008
Posts: 1,637
Received Thanks: 1,119
|
Jede Methode einzeln als public zu deklarieren ist nicht nötig.
Hinter der abschließenden Klammer sollte ein Semikolon stehen.
Nutzt nur die "Instance" Methode den Konstruktor? Zumindest erlaubst du dem Compiler nicht, den Konstruktor von woanders aufzurufen. Wobei das auch einen anderen Fehler verursachen würde, wie wird der genau aufgerufen?
|
|
|
 |
Similar Threads
|
[ENG] Error: Error 1 error C2601: 'HackMain' local function definitions are illegal
08/20/2013 - C/C++ - 1 Replies
So, as the title says I've been encountering an error
Error 1 error C2601: 'HackMain' local function definitions are illegal
I'm running on VC++ (Visual C++)
This is my code:
void HackMain()
{
for (;; )
{
HackThread();
}
|
[Tool] Extract Protocol Message Definitions
09/15/2012 - DarkOrbit - 3 Replies
Here you go, everything is explained in the top comment.
Does not work for Messages that contain arrays of others.
/* This program will create struct definitions for Darkorbit protocol.
* If you see "Attention Array" anywhere, you have to manualy work out that packet!
* Beforehand you need to decompile the .swf . showmycode.com works great for that.
* Point this program to the commands folder in ...\net\bigpoint\darkorbit\net\netty folder.
*/
using System; using...
|
[Tool] Extract Protocol Message Definitions 0.2
08/21/2012 - DarkOrbit - 13 Replies
Here is a quick rewrite of my client<->server messages extractor.
It uses the output of as3sorcerer as input and outputs the messages in json. This json file you can then further parse to do whatever you like with it.
Extract Protocol Message Definitions 0.2 - Pastebin.com
Advantages of new version:
- easier to read, because of python
- better output
- will support automatic id updating on changed id's in the future (for rev. 0.3)
|
Finde definitions zahl nicht
07/24/2010 - AutoIt - 2 Replies
Also das Script wurde von darter gekürzt nun finde ich aber die zahlen nicht mehr von den checkboxen die ich aber dringend bräuchte damit der bot weiß ob er den link aufrufen soll oder nicht. Wenn ihr noch fehler findet sagts pls. hier mein aktueller code.
#include <String.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Peter...
|
All times are GMT +1. The time now is 15:44.
|
|