Manutebecker 0 Junior Poster in Training

For instance... I have the class Deck, which represents a deck of cards, and I want another class, derived from that, called cards, I want class Deck to have a class array called Cards[52], so I can assign all the different values and strings to the individual Cards class instances and have the class Deck do things to the deck as a whole... Im talkin something like this

class Deck{
protected:
class Cards[52];   // This doesnt work to have multiple instances in the class

public:
void Shuffle();

};

class Cards : public Deck{
Cards(int,string);
};

ik that you might not understand why i want to do this in two different classes, but i do... so please just gimme a clear cut answer. please and thank you!

Manutebecker 0 Junior Poster in Training

There is absolutely no point in using a pointer...

Manutebecker 0 Junior Poster in Training

Ugh you guys are awesome, thx :P

Manutebecker 0 Junior Poster in Training

I switched from Dev-C++ to Code::Blocks. No difference in compiler (I use MinGW), but I like the GUI a lot more than Dev's.

This...

Manutebecker 0 Junior Poster in Training

Which is in higher demand in the job market right now???

Manutebecker 0 Junior Poster in Training

I have a question, why, when your setting up a constructor, do you declare all the objects values in the cpp file, yet comment the exact stuff in the header, why not just do it all initial constructor

Manutebecker 0 Junior Poster in Training

Just curious to see who has memorized the 70 or so lines to create a window, I for one am almost to the point of having it totally memorized, and I also know what it all means, thats obviously important :P

Manutebecker 0 Junior Poster in Training

Yes, I've been teaching myself for awhile. I'm fine with most aspects, its just pointers have always kicked my ass in one way or another, like the compiler will expect me to put something in that pointing to the pointer of something (**) and I'll google, not figure it out, then just post here. This is due to the fact that you guys rawk!!! thx much skata :)

Manutebecker 0 Junior Poster in Training

Noone on here, I can nearly say I am 100 percent positive, will give an honest answer of anything besides C, you pie chart is done, very bad poll dude, no offense

Manutebecker 0 Junior Poster in Training

yeah I actually had it on a seperate pc and didnt ctrl v it onto here, rather quickly interpreted it, my bad, but thx a lot, and one last thing, I tried to add a function called

char getName(){return *Name;}

However it only returns the first letter, god I fail

Manutebecker 0 Junior Poster in Training

ugh can you just show me what you would do in the int main() too I'm really having severe problems, me and pointers are just not friends

Manutebecker 0 Junior Poster in Training

So I'm having trouble with classes today, I want to do something like

#include <iostream.h>
using namespace std;
class Dummy{
char Name[256];
void setName(char nam){Name=nam;}
};

int main(){
char[256] temp;
cout << "Name?\n";
cin >>  temp;
setName(temp);
}

I want something like this to store a char array in a class, but it never works, I've googled all this stuff and just cant find it, Help!

Manutebecker 0 Junior Poster in Training

WTF, I went into your program and changed the 2 to a three and my computer started beeping about 3 times a second and printing off weird symbols on the console, i nearly messed myself

Manutebecker 0 Junior Poster in Training

so far ty, however i have 2 questions, I dont know why I need a const in there, and I cant find any really helpful tuts on polymorphism and class deriving, can you lead me to a good one :P

Manutebecker 0 Junior Poster in Training

I want to create a battle system for an RPG game, one a little more robust then the previous one I made. This one I want to be very dynamic and easy to use. I want to use the Allegro API for it, but first I want to make sure I have everything going good in console before I put it into a real time rpg, but I'm having technical difficulties...

Now here are my classes...

class Game{
};

class Boxer:Game{
    public:
        char name[256];
        int health, *attack, level, critchance,xp,requiredxp;
        int Attack(){return -(*attack-rand()%(level/2));}
        void setName(){}
        void AdjustXP(int x){xp+=x;}
        void     Spash(){printf("HP:%d\tXP:%d/%d\n",health,xp,requiredxp);}
        void EveryFrame(){*attack=level*3;}
        Boxer(){health=25;level=15;requiredxp=level*5,xp=0;}
};



class Battle:Game{
    public:
        void Attack(int  attackerhit, int * attackeehp){*attackeehp+=attackerhit;}
};

int main(){
srand(time(NULL));
Boxer Boxer; 
Battle Battle;
int attack=5;
Battle.Attack(attack,Boxer->hp) //??? Heres my problem I believe
cout<<Boxer.hp;
}

Right now I want to pass the Boxer class' HP through a pointer to the Battle Classes Attack function, while passing a normal int (since the attack really doesnt need to be adjusted as of now). I get really weird errors like no matching function for call to `Battle::Battle(int&, int)'|... Please help!!!

Manutebecker 0 Junior Poster in Training

I prefer to derive

Manutebecker 0 Junior Poster in Training

thx :)

Manutebecker 0 Junior Poster in Training

Learn how to fully use the windows header with help from
Windows.h Tutorial, I'm pretty well along in the Programming world and was wondering if this would be really useful in becoming a programmer in the future.

Manutebecker 0 Junior Poster in Training
#include "verySmallViolins.h"

Absolutely essential when handing in homework that is late.

LMAO thats great!!!

Manutebecker 0 Junior Poster in Training

If I use things from another class I tend to just do a heirarchy, branching one off another and protecting the values i want only in the heirarchy, for example

class Mother{
};

class Son: Mother   //Mom class Births Son Class :P
{
};
Manutebecker 0 Junior Poster in Training
//Deck Class
#include<iostream>
#include<stdlib.h>

using namespace std;


class Deck{
    int Cards[51];
public:
    Deck();
    void Display();
    void Shuffle();
};


Deck::Deck(){
    for(int n = 0; n < 52; n++){
        Cards[n]=n;
    }
}

void Deck::Display(){
    for(int n = 0; n < 52; n++){
        cout << n+1 << ". " << Cards[rand()%51] <<endl;
    }}

void Deck::Shuffle(){
    for(int n = 0;n < 52; n++){
        int r=n+(rand()%(52-n));
        int temp=Cards[n];
        Cards[n]=Cards[r];Cards[r]=temp;
    }}

This is what I have so far for card class, I want to categorize them into the suits then to the number they are. So like a two of clubs would be assigned to number 22 or something. How would I get it so it can detect what is a club and what isn't, same with numbers/face cards... I was told by a friend to use Enums but I wanted to know if there was any more efficient way

Manutebecker 0 Junior Poster in Training

I must say I always love a program where I can use #include<vector> vectors are like the peanut butter to my chocolate!

Manutebecker 0 Junior Poster in Training

I figured it out on my own, but BeyondTheEye gave a pretty good description, REP!!!

Manutebecker 0 Junior Poster in Training

What I want to do is make a grading system. There is a vector for schools and classes and students, all of these which have their own class, derived from a class called system.

class System{
School * p; //School Pointer
vector<School>sSort;
public:
    //Splash Screen Function
    void Splash();
};

/*-School Class High-*/
class School : public System{
public:

    /*-Variables of School-*/
    string schoolname;
    double averageGPA;

    /*-Functions-*/

};


/*-Student Class High-*/
class Student : public School{
};

What I want to be able to do is make there be many instances of the School class, and each school has its own body of students and would need its own vector sort, and each student has their grades, which I would also like to be "vectorized". How would I make vectors in multiple classes, I only really know how to do so in the main function.

Manutebecker 0 Junior Poster in Training

After reading up on them in terms of class hierarchy, they seem to just be almost like comments, to remind you that all classes use this sort of function

Manutebecker 0 Junior Poster in Training

I've been reading up on templates and they just seem like so much hastle for so little reward. I can't find anyway to effectively use it over vectors. I am just having a lot of trouble learning them because the concept seems so weird.

Manutebecker 0 Junior Poster in Training

I suggest Allegro, its an excellent API, my favorite for 2d work
allegro.cc

Manutebecker 0 Junior Poster in Training

thx, but I need to be able to put data into those for statements and theres no call for them in the function, wouldn't I need to use a typedef or something like that?

Manutebecker 0 Junior Poster in Training

for(int n = 0; n<blocksx;n++){
for(int x = 0; x<blocksy;x++){

I just want to be able to shorten this into something easy so I could just type in like one word to get it to work, it is used a lot and sucks to retype... thx

Manutebecker 0 Junior Poster in Training

I want to be able to bring the single instance class into a function of another class without having to take each seperate little variable from the class and inject it in, can I just do something like

void Yeah(class *The Class)

and then pass the class in easily??? Or maybe even in a non pointer form?

Manutebecker 0 Junior Poster in Training

Your question is difficult to understand, but if you mean will it construct what you have in a default constructor to each instance of said class, then yes it should.

Manutebecker 0 Junior Poster in Training

well its in the api allegro, I want two public classes to share variables and use eachothers functions

Manutebecker 0 Junior Poster in Training

Topic... just wondering if it would be friend or pointers in the main or something else...

Manutebecker 0 Junior Poster in Training

yeah I was just messing around with pointers, ill get rid of em and report back to you guys sometime later, its 7 am here and I'm tired as hell... Night

Manutebecker 0 Junior Poster in Training

I want integers 1-52 to be drawn only once, so every "card" will be seen and not one picked twice, heres the code

#include<iostream>
#include<time.h>
#include<string>
#include<stdlib.h>
using namespace std;
class Player{
      int hand;
      
      };
int main()
{
    srand(time(NULL));
    int deck=53;
    int *drawn;
    int notdraw[52];
    for (int n=1;n<53;n++)
    {
        deck-=1;
        drawn = new int;
        *drawn = rand() % 52+1;
        for (int i = 0; i <n; i++)
        {
            while(*drawn==notdraw[i])
            {
                                 delete drawn;
                                 drawn = new int;
                                 *drawn = rand() % 52+1;
                                 }
                                 }
            
        cout << deck << ". " << *drawn << endl;
        notdraw[n]= *drawn;
        delete drawn;
        }
        cout << deck << endl;
        system("PAUSE");
        }

Ignore the class, Ill be messing with it later

Manutebecker 0 Junior Poster in Training

yeah sorry guys I had been thinkin about it for a while but posting this unclogged my mind, a little snippet of how I did it

#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<string>
using namespace std;

int main(){
      srand (time(NULL));
      int *drawn;
      int nodraw[52];
      for (int n=0;n<52;n++)
      {
      drawn = new int;
      *drawn = rand() %52+1;
     
      cout << n+1 << ". " <<*drawn << endl;
       for(int x=n;x>0;x--)
      {
              if (*drawn == nodraw[x])
              {
                       cout << "Repeat" << endl;
                       }
      nodraw[n]=*drawn;
              }
      delete drawn;
      }
      system("PAUSE");
      }

sorry guys...

Manutebecker 0 Junior Poster in Training

All I need to know is how a good way to make sure integers between 1 and 52 wont be draw twice over in a for statement... I was thinking something like

srand (time(NULL));
int *drawn;            //The card to be drawn
int notdraw[52];    // All the cards that have already been drawn and should not be drawn again...
for (n=0;n<52;n++)
{
*drawn = new int;
drawn =  rand() % 52+1;
drawn = notdraw[n]
delete draw;
}

thats where I get jumbled up... Just been thinking of putting a for statement in that will process the drawn to look over every notdrawn and ensure its not using one of them... um did I just answer my own question... anyway plz help

Manutebecker 0 Junior Poster in Training

dude you should take the time to comment your code, its really quick and goes a long way in speeding up the debug process, what class is this for, intro to C++ or an advanced one or what??? What year of college you in too

Manutebecker 0 Junior Poster in Training

I hate VC++, its just such a pain to get going, I perfer Dev C++ for ease of use(though it has a lame debugger)

Manutebecker 0 Junior Poster in Training

If you're going to be a jackass go ahead and refrain from using your keyboard, no one wants to read your insolence. He asked for help, not destructive criticism.

Regardless, I have to agree that a fair amount of the time if you read the compiler message, you will generally be able to decipher what is actually wrong with your code.

I am actually programming essentially the exact same application right now for a test and I share one of your errors, but I have no idea how to fix it.

One thing I do suggest though is to separate your class definitions and driver files. When you are debugging it helps tremendously in locating exactly where something is going wrong.

the criticism seemed constructive IMO, the error was blatantly obvious

Manutebecker 0 Junior Poster in Training

shouldn't this be in the c# board, i bet they know both c++ and (obviously) c-sharp, we tend to only know the former...

Manutebecker 0 Junior Poster in Training

Just wanted to know, I'm just doing a little dice rolling thing thats storing dice values according to how many times they come up every so often, just wondering if instead of making 50 lines of code doing
if(sum==1)
{
ones+=1;
}
else if(sum==2)
{...
and so on,
I'm thinking of arrays and stuff but cant come up with anything, I like my code to be short and effective, I HATE if-thens if used like I have it above and would like to use a more clever way.

Manutebecker 0 Junior Poster in Training

thx guys would love to hear more about what your programming life has been like though, what libraries and stuff you used, but feedback is good too!!! :P

Manutebecker 0 Junior Poster in Training

hmm... your code has me thoroughly confused, i wont lie... why not try something like including putting
#include<io.h> at the top...
then when you get to copying the things,
then throw in CopyFile("slav1.txt","slav2.txt",TRUE)... this should work, although I heard it wont work if you use linux... hope I helped somewhat :P

Manutebecker 0 Junior Poster in Training

What confuses me is that you are doing a cout on a function that you need to interact with... you should split the two into two seperate functions within the class, one being a setBool, the other being a getBool

Manutebecker 0 Junior Poster in Training

I did Hello world about a month ago, (my first language was BASIC), and now im onto things like Templates and I got all of my classes pointers and filing stuff down fine...Im trying to get OpenGL and SDL going (I'm already doing pretty good with the Allegro library). Idk if thats good or bad for a months work, Im using C++ for dummies and online tuts right now... I'm 17 btw and just learning out of my bedroom comp, just sit around till 8am learning video game programming and straight up programming (I do other stuff too of course)...
How am I looking in terms of learning speed....
I also really wanna know what it was like for your guys' learning speed and when you learned a new library and at what age!

Manutebecker 0 Junior Poster in Training

still doesnt work, any specific header for this, just dont work on dev c++

Manutebecker 0 Junior Poster in Training

I wanna have my program be able to let the user manually open a text file by destination and retrieve data from it, I have everything like ifstream good, i just need to know how to let the user cin something like C:/files/myfile.txt, but with the ifstream format I need to use the format ifstream stringname("texthere"); but cant let the user modify the "texthere", im sure its just a simply command, plz help

Manutebecker 0 Junior Poster in Training

excellent!!! respond degrading my advice and not explain why its "bad"... HOORAY!!!

Manutebecker 0 Junior Poster in Training

just wanted to say (even though this is closed)... make the int small global (declare it just before int main().
Globalizing variables ROX!!!