Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [C++] syntax error: identifier 'MapColour'
New Posts  All Forums:Forum Nav:

[C++] syntax error: identifier 'MapColour'

post #1 of 11
Thread Starter 
Hi all, just having an error on compile related to the class prototype in one of my headers:
Error: error C2061: syntax error : identifier 'MapColour' (its in the Material.h file)
Code:
Material.h
Code:
#pragma once
#include "global.h"
#include "MapColour.h"

class Material
{
public:
Material() { };
Material(MapColour* mapcolour);
bool getCanBlockGrass() { return true; };

MapColour* theMapColour1;
private:
bool initBool;
};
Code for Material.cpp:
Code:
#include "Material.h"

Material::Material(MapColour* mapcolour)
{
initBool = true;
theMapColour1 = mapcolour;
}
Code for MapColour.h:
Code:
#pragma once
#include "global.h"

class MapColour
{
public:
MapColour() { };
MapColour(int i, int j);

int fieldI, fieldJ;

MapColour* mapArrayField[16];
};
Code for MapColour.cpp:
Code:
#include "MapColour.h"

MapColour::MapColour(int i, int j)
{
fieldI = i;
fieldJ = j;
for(int i = 0; i < 16; i++)
{
mapArrayField[i] = new MapColour();
}
}
Thanks, FiX
Edited by FiX - 8/10/11 at 1:29am
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #2 of 11
I've just looked at this briefly, but aren't you missing #define for your headers? Also, why are you using #pragma once ?
post #3 of 11
Thread Starter 
Quote:
Originally Posted by SafeKlok View Post
I've just looked at this briefly, but aren't you missing #define for your headers? Also, why are you using #pragma once ?
You mean like:
Code:
#ifndef MAPCOLOUR_H
#define MAPCOLOUR_H
..header code..
#endif
#pragma once does the same thing
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #4 of 11
Which line? Make it bold or something.
Akiyama Mio
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6420 @ stock, 0.98v Asus P5N-E SLI Gainward GTX 460 1GB @ 800/1600/1900 2x2GB Kingston @ 800MHz 5-5-5-15 2T 
Hard DriveOptical DriveOSMonitor
WD 250GB, 320GB SATA/3, 16MB Cache, Seagate 1TB LG GSA-H62N 18x SATA Ubuntu 9.10 x86 & Win7 x86 Asus VW222U 
KeyboardPowerCase
Logitech Classic Corsair 650HX NZXT Apollo Black 
  hide details  
Reply
Akiyama Mio
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6420 @ stock, 0.98v Asus P5N-E SLI Gainward GTX 460 1GB @ 800/1600/1900 2x2GB Kingston @ 800MHz 5-5-5-15 2T 
Hard DriveOptical DriveOSMonitor
WD 250GB, 320GB SATA/3, 16MB Cache, Seagate 1TB LG GSA-H62N 18x SATA Ubuntu 9.10 x86 & Win7 x86 Asus VW222U 
KeyboardPowerCase
Logitech Classic Corsair 650HX NZXT Apollo Black 
  hide details  
Reply
post #5 of 11
I see nothing wrong with the posted code. It compiles fine with GCC(after removing the #include "global.h" lines). What compiler are you using and does it support #pragma once?

Make sure there are no issues inside global.h, and that you are compiling the most recent version of your code. Delete any existing binaries to ensure that you are not compiling against an outdated binary. Also disable any caching tools you might be using such as ccache.
BlackBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 3.6ghz @ 1.35V Gigabyte X38-DS4 ATI 5870 4GB Corsair Dominator 1033Mhz 
Hard DriveOSMonitorKeyboard
Hitachi P7K500 320GB 64-bit Gentoo Linux / 64-bit Vista Ultimate Sceptre X24-WG 24" WUXGA Deck 82-key 
PowerCaseMouse
Corsair 750TX BlackBox (scratch built) Logitech G5 
  hide details  
Reply
BlackBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 3.6ghz @ 1.35V Gigabyte X38-DS4 ATI 5870 4GB Corsair Dominator 1033Mhz 
Hard DriveOSMonitorKeyboard
Hitachi P7K500 320GB 64-bit Gentoo Linux / 64-bit Vista Ultimate Sceptre X24-WG 24" WUXGA Deck 82-key 
PowerCaseMouse
Corsair 750TX BlackBox (scratch built) Logitech G5 
  hide details  
Reply
post #6 of 11
Thread Starter 
Okay, Im using Visual Studio 2010, and whatever compiler it comes with. The #pragma once has worked fine before, Il try fully rebuilding the project. global.h just contains a load of includes to the STL
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #7 of 11
Sorry, to clarify what I said earlier, why are you using #pragma once and not #ifndef, as pragma once is non-standard.
post #8 of 11
Thread Starter 
Quote:
Originally Posted by SafeKlok View Post
Sorry, to clarify what I said earlier, why are you using #pragma once and not #ifndef, as pragma once is non-standard.
In short, because Im lazy and it worked. Sounds like a pain to go through all of the 30 headers and replace it all.
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #9 of 11
Thread Starter 
I have no idea what I did, but Iv sort of got it working now (well that bit of code). New error now
Quote:
error C2143: syntax error : missing ';' before 'using'
Code:
Code:
#pragma once 
#include <iostream>
using namespace std;

class StepSound
{
public:
StepSound(string s, float soundVolume, float soundPitch)
{
soundStepName = s;
volume = soundVolume;
pitch = soundPitch;
}

float getVolume()
{
return volume;
}

float getPitch()
{
return pitch;
}

string getSoundName()
{
string temp = "step.";
temp.append(soundStepName);
return temp;
}

string soundStepName;
float volume, pitch;
};
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #10 of 11
Thread Starter 
Sorry about triple post but, fixed now. One of the unrelated classes was missing a ; at the end. Just got linking errors but those shouldnt be too hard to fix as their related to my static members of functions REP+ for those who helped.
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [C++] syntax error: identifier 'MapColour'