C++ I got stuck with 2 errors

Hello
I cannot figure out by myself these errors:
error C2143: syntax error : missing ';' before 'using'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I surfed the web but I'm still stuck; I believe my problem it's with the Windows Headers.
I looked here( http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx ) but nothing..
I'm using Visual C++ 2010 Express and my OS is XP 32-bit.

// CODE Cardgame.h
#ifndef CARDGAME_H
#define CARDGAME_H
using namespace std;
#pragma once
class Cardgame
{
int players;
static int totalparticipants;
public:
Cardgame(int p);
~Cardgame(void);
};
#endif

// CODE Cardgame.cpp:
#define NTDDI_WINXP 0x05010000
#define _WIN32_WINNT_WINXP 0x0501
#include "Cardgame.h"
#include <iostream>
using namespace std;

Cardgame::Cardgame(int p)
{
players = p;
totalparticipants += p;
cout << p << " players have started a new game. There are now "
<< totalparticipants << " players in total." << endl;
}
Cardgame::~Cardgame(void)
{
}

// CODE testgame.cpp:
#include <iostream>
#define NTDDI_WINXP 0x05010000
#define _WIN32_WINNT_WINXP 0x0501
#include "Cardgame.h"
int Cardgame::totalparticipants = 0;
int main()
{
Cardgame *bridge = 0;
Cardgame *blackjack = 0;
Cardgame *solitaire = 0;
Cardgame *poker = 0;
bridge = new Cardgame(4);
blackjack = new Cardgame(8);
solitaire = new Cardgame(1);
delete blackjack;
delete bridge;
poker = new Cardgame(5);
delete solitaire;
delete poker;
return 0;
}

Any help that you can provide will be appreciated.
Thanks
Cardgame.h:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once

#ifndef CARDGAME_H
#define CARDGAME_H

using namespace std;

class Cardgame
{
private:
    int players;
    static int totalparticipants;
public:
    Cardgame(int p);
    ~Cardgame(void);
};

#endif 


Cardgame.cpp & testgame.cpp:

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
#define NTDDI_WINXP 0x05010000
#define _WIN32_WINNT_WINXP 0x0501

#include "Cardgame.h"
#include <iostream>

using namespace std;

// Constructor
Cardgame::Cardgame(int p)
{
    players = p;
    totalparticipants += p;
    cout << p << " players have started a new game. There are now "
    << totalparticipants << " players in total." << endl;
}

// Deconstructor
Cardgame::~Cardgame(void)
{

}

int Cardgame::totalparticipants = 0;

int main()
{
    Cardgame *bridge = 0;
    Cardgame *blackjack = 0;
    Cardgame *solitaire = 0;
    Cardgame *poker = 0;

    bridge = new Cardgame(4);
    blackjack = new Cardgame(8);
    solitaire = new Cardgame(1);

    delete blackjack;
    delete bridge;

    poker = new Cardgame(5);

    delete solitaire;
    delete poker;
    return 0;
}


Fixed up the header and combined your two .cpp files into one.

Also cleaned up the indention.

No errors when compiling.

:-)
Last edited on
Topic archived. No new replies allowed.