"undeclared identifier" error

This is a discussion on "undeclared identifier" error within the C++ Programming forums, part of the General Programming Boards category; Code: #include <string> #include <vector> using std::string; using std::vector; using std::cout; using std::endl; #define MAX_ITEMS 100 #define MAX_INV 30 class ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    84

    "undeclared identifier" error

    Code:
    #include <string>
    #include <vector>
    using std::string;
    using std::vector;
    using std::cout;
    using std::endl;
    
    #define MAX_ITEMS 100
    #define MAX_INV 30
    
    class Items
    {
    public:
    
    	Items (int A, int B, int C, int D, int E, int F, int G, int H, int I, int J, int K,
    		int L, int M, int N, int O, int P, int Q, int R, int S, int T, int U, int V, int W, int X,
    		int Y, int Z, int AA, int AB, string AC, string AD, double AE, double AF)
    	{
    		int ID = A;
    		int mainClass = B;
    		int subClass = C;
    		int grade = D;
    		int quality = E;
    		int degree = F;
    		int bonding = G;
    		int price = H;
    		int stackSize = I;
    		int primDmg[] = {J,K,L};  // first element directly adds to the needed stat
    		int sconDmg[] = {M,N,O};  // first element directly adds to the needed stat
    		int resist[] = {P,Q,R};
    		int bnsOpt[] = {S,T,U,V,W,X,Y,Z,AA,AB};  //each array here is directly added to the player stats
    	    string name = AC;
    	    string desc = AD;
    		double attSpeed = AE;
    		double defSpeed = AF;};
    
    		int ArmRes(){return (resist[0]*Quality())*Grade();}
    		int EleRes(){return (resist[1]*Quality())*Grade();}
    		int MagRes(){return (resist[2]*Quality())*Grade();}
    
    		int MinDmg(){return (primDmg[1]*Quality())*Grade();}
    		int MaxDmg(){return (primDmg[2]*Quality())*Grade();}
    		int Min2Dmg(){return (primDmg[1]*Quality())*Grade();}
    		int Max2Dmg(){return (primDmg[2]*Quality())*Grade();}
    
    
    
    		double Quality()
    		{
    			if (quality==0) return 0.7;
    			if (quality==1) return 1.0;
    			if (quality==2) return 1.3;
    			if (quality==3) return 1.7;
    			if (quality==4) return 2.1;
    			if (quality==5) return 2.6;
    			if (quality==6) return 3.1;}
    
    		double Grade()
    		{
    			if (grade==0) return 1.0;
    			if (grade==1) return 1.1;
    			if (grade==2) return 1.2;
    			if (grade==3) return 1.4;
    			if (grade==4) return 1.6;
    			if (grade==5) return 2.0;
    			if (grade==6) return 2.4;
    		    if (grade==7) return 3.2;}
    
    		double Degree()
    		{
    			if (degree==0) return 1.0;
    			if (degree==1) return 1.1;
    			if (degree==2) return 1.2;
    			if (degree==3) return 1.4;
    			if (degree==4) return 1.6;
    			if (degree==5) return 1.9;
    			if (degree==6) return 2.2;
    		    if (degree==7) return 2.6;
    			if (degree==8) return 3.0;
    			if (degree==9) return 3.5;
    			if (degree==10) return 4.0;
    			if (degree==11) return 4.6;
    			if (degree==12) return 5.2;
    			if (degree==13) return 5.9;
    			if (degree==14) return 6.6;}
    
    		void showOpts()
    		{
    			string type;
    			for (int iii=0; iii!=10; iii++;)
    				if (bnsOpt[iii]!=0)
    				{
    					if (iii==0)
    						type = "DEX";
    					else if (iii==1)
    						type = "STR";
    					else continue;
    					
    					cout << "Adds" << bnsOpt[iii] << type << endl;} }
    
    		void descrWin()
    		{
    			/*showName();
    			showInf1();
    			showDesc();
    			showStts();*/
    			showOpts();
    			/*showInf2();*/}
    
    
    }charEqup[10];
    ------ Build started: Project: Helios RPG - Beta, Configuration: Release Win32 ------
    Compiling...
    Main.cpp
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(111) : error C2512: 'Items' : no appropriate default constructor available
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(37) : error C2065: 'resist' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(38) : error C2065: 'resist' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(39) : error C2065: 'resist' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(41) : error C2065: 'primDmg' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(42) : error C2065: 'primDmg' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(43) : error C2065: 'primDmg' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(44) : error C2065: 'primDmg' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(50) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(51) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(52) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(53) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(54) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(55) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(56) : error C2065: 'quality' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(60) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(61) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(62) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(63) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(64) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(65) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(66) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(67) : error C2065: 'grade' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(71) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(72) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(73) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(74) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(75) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(76) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(77) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(78) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(79) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(80) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(81) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(82) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(83) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(84) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(85) : error C2065: 'degree' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(90) : error C2059: syntax error : ';'
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(91) : error C2065: 'bnsOpt' : undeclared identifier
    c:\documents and settings\eng\my documents\visual studio 2008\projects\project1\helios rpg - beta\helios rpg - beta\Items.h(99) : error C2065: 'bnsOpt' : undeclared identifier
    Build log was saved at "file://c:\Documents and Settings\eng\My Documents\Visual Studio 2008\Projects\Project1\Helios RPG - Beta\Helios RPG - Beta\Release\BuildLog.htm"
    Helios RPG - Beta - 41 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Whats the problem? even when I tried declaring them outside the constructor it still gave me the same error together with more "undeclared identifier" errors.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    grade, degree and quality are not members of the class, but local variables in the constructor. They will disappear again when the constructor is finished.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    84
    Quote Originally Posted by matsp View Post
    grade, degree and quality are not members of the class, but local variables in the constructor. They will disappear again when the constructor is finished.

    --
    Mats
    But I said, even when I declared them outside the constructor I had the same problem.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Then you'd better post that code - it would probably help if the example you post is a bit smaller too.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    84
    Quote Originally Posted by matsp View Post
    Then you'd better post that code - it would probably help if the example you post is a bit smaller too.

    --
    Mats
    Oh nevermind, it seems like I made some little mistake when I tried to define everything outside the class, thanks alot for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02:17 PM
  3. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 03:39 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21