![]() |
| | #1 | |
| Registered User Join Date: May 2009
Posts: 84
| problem Code: #include <string>
#include <vector>
using namespace std;
#define MAX_RACES 3
#define MANA_S 1
#define SPIRIT_S 2
#define ANCIENA_S 3
class Races
{
public:
Races (int A, int B, string C, string D, string E, float F, float G, float H, float I, float J, float K,
float L, float M, float N, float O, float P, float Q, float R)
{
int ID = A;
int magSkil = B;
string name = C;
string energy = D;
string pPoint = E;
float attGrw[] = {F,G,H,I};
float eleRes[] = {J,K,L};
float phyRes[] = (M,N,O};
float magRes[] = {P,Q,R}; };
}vector<Races>racesDB, *charRace;
void LoadRaces()
{
racesDB.push_back;
racesDB[1].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
racesDB.push_back;
racesDB[2].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
racesDB.push_back;
racesDB[3].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
}
Quote:
| |
| ExDHaos is offline | |
| | #2 | |
| Registered User Join Date: May 2009
Posts: 84
| Code: }*charRace;
void LoadRaces()
{
vector<Races>racesDB
racesDB[0].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
racesDB.push_back;
racesDB[1].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
racesDB.push_back;
racesDB[2].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
}
Quote:
| |
| ExDHaos is offline | |
| | #3 | |
| Registered User Join Date: May 2009
Posts: 84
| Code: #include <string>
#include <vector>
using namespace std;
#define MANA_S 1
#define SPIRIT_S 2
#define ANCIENA_S 3
class Races
{
public:
Races (int A, int B, string C, string D, string E, float F, float G, float H, float I, float J, float K,
float L, float M, float N, float O, float P, float Q, float R)
{
int ID = A;
int magSkil = B;
string name = C;
string energy = D;
string pPoint = E;
float attGrw[] = {F,G,H,I};
float resGrw[][] = {J,K,L},(M,N,O},{P,Q,R}; };
}*charRace;
void LoadRaces()
{
vector<Races>racesDB;
/*racesDB[0].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
racesDB.push_back;
racesDB[1].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
racesDB.push_back;
racesDB[2].Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);*/
}
Quote:
| |
| ExDHaos is offline | |
| | #4 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| The errors aside, a function that takes almost the whole alphabet in single character input parameters is DEFINITELY wrong. At the very least, give each parameter a decent name! [And ABSOLUTELY, do not use O as a variable name - in many fonts, it's almost impossible to tell O from 0, so you may think reading the code that x = O; means that x is zero]. You probably want to package some of those parameters into their own struct/class, and pass the whole bunch at once. Code: int ID = A;
int magSkil = B;
string name = C;
string energy = D;
string pPoint = E;
float attGrw[] = {F,G,H,I};
float resGrw[][] = {J,K,L},(M,N,O},{P,Q,R};
The error about resGrw missing subscript is that when you have multidimensional arrays, even when initializing them, you need to give all dimensions except the rightmost one. And you are missing the outer set of braces around the initialization. It seems like the code you have posted is a header file. This: Code: using namespace std; -- 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. |
| matsp is offline | |
| | #5 | |
| Registered User Join Date: May 2009
Posts: 84
| Quote:
P.S: I ALWAYS use the std, so it doesn't matter. And I need the std for the strings (if I remove the std it gives twice more errors) | |
| ExDHaos is offline | |
| | #6 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
As to the actual error, part of it is what I pointed out earlier: you are missing a pair of braces. The rest of them are because you have mixed up a left parenthesis with a brace, and the compiler gets very confused because it gets "lost". To clarify "lost" here: If you imagine that you are telling your friend how to drive to your house, you tell your friend "Take the first left after the big oak-tree on the right, then the second right and then first left after the traffic lights", but unknown to you, someone cut down the big oak-tree. So your friend drives right past where the oak-tree was, and another 2 miles down the road, where there is another large oak... Now, it's all a mess, and your friend is likely to NEVER find your house without asking you again! Parenthesis, braces, brackets and semicolons are "road markers" for the compiler, so if there is one missing, or too many, and the compiler will not know what it's up to. -- 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. | |
| matsp is offline | |
| | #7 | |
| Registered User Join Date: May 2009
Posts: 84
| Quote:
| |
| ExDHaos is offline | |
| | #8 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Do you mean like this? Code: class x
{
std::vector<int> v;
...
}
-- 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. |
| matsp is offline | |
| | #9 |
| Registered User Join Date: May 2009
Posts: 84
| |
| ExDHaos is offline | |
| | #10 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Seeing as I don't fully understand WHAT you are trying to achieve, that makes it very hard to explain how you SHOULD do that. -- 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. |
| matsp is offline | |
| | #11 | |
| Registered User Join Date: May 2009
Posts: 84
| Quote:
Code: }classesDB[MAX_CLASSES], *charClass;
void LoadClasses()
{
classesDB[0].classInfo(3, "Warrior", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
}
| |
| ExDHaos is offline | |
| | #12 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| So, you either size/resize your vector as need be, or you create a temporary object and add it using push_back(). -- 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. |
| matsp is offline | |
| | #13 | |
| Registered User Join Date: May 2009
Posts: 84
| Quote:
Code: void LoadRaces()
{
vector<Races>racesDB;
racesDB.push_back(Races(1, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5));
racesDB.push_back(Races(2, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5));
racesDB.push_back(Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5));
}
| |
| ExDHaos is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help understanding a problem | dnguyen1022 | C++ Programming | 2 | 04-29-2009 04:21 PM |
| Memory problem with Borland C 3.1 | AZ1699 | C Programming | 16 | 11-16-2007 11:22 AM |
| Someone having same problem with Code Block? | ofayto | C++ Programming | 1 | 07-12-2007 08:38 AM |
| A question related to strcmp | meili100 | C++ Programming | 6 | 07-07-2007 02:51 PM |
| WS_POPUP, continuation of old problem | blurrymadness | Windows Programming | 1 | 04-20-2007 06:54 PM |