Click here to Skip to main content
16,010,427 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Really strange problem , solution !!! :-) Pin
Rage25-May-03 22:39
professionalRage25-May-03 22:39 
GeneralRe: Really strange problem , solution !!! :-) Pin
Neville Franks25-May-03 22:46
Neville Franks25-May-03 22:46 
GeneralGet File Type Extenstons.......... Pin
rohit.dhamija25-May-03 20:44
rohit.dhamija25-May-03 20:44 
GeneralRe: Get File Type Extenstons.......... Pin
Rage25-May-03 22:57
professionalRage25-May-03 22:57 
GeneralRe: Get File Type Extenstons.......... Pin
rohit.dhamija25-May-03 23:33
rohit.dhamija25-May-03 23:33 
QuestionWill the professional programmers please help me here with my DieClass? Pin
Link260025-May-03 19:15
Link260025-May-03 19:15 
AnswerRe: Will the professional programmers please help me here with my DieClass? Pin
Michael Dunn25-May-03 19:33
sitebuilderMichael Dunn25-May-03 19:33 
AnswerRe: Will the professional programmers please help me here with my DieClass? Pin
Xander8025-May-03 19:35
Xander8025-May-03 19:35 
I've changed a few things in youre code. Does this work???

// DieTest.cpp
// the driver

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

void main()
{
Die d1, d2;
Die d3(10), d4(100);

cout << "d1\td2\td3\td4" << endl;

for (int i=0; i<10; ++i)
{
d1.roll(); // roll() is modifier
d2.roll();
d3.roll();
d4.roll();

cout << d1.getValue() << '\t'; // getValue() is asscessor
cout << d2.getValue() << '\t';
cout << d3.getValue() << '\t';
cout << d4.getValue() << '\t';
}
cin.get();
}


// Die.cpp
// the implementation

#include <stdlib.h>
#include <time.h>
#include "Die.h"

Die::Die() // Die() is a constructor
{
nSides = DEFSIDES;
value = 1;
}

Die::Die(int sides)
{
nSides = sides;
value = 1;
srand( (unsigned)time( NULL ) );
}

void Die::roll() // roll() is a modifier
{
value = (rand()%nSides)+1;
}

int Die::getValue()
{
return value;
}




//Die.h
// the header

#ifndef DIE_h
#define DIE_h

const int DEFSIDES = 6;

class Die
{
public:
// constructor
Die();
Die(int);
void roll(); // modifier
int getValue(); // asscessor

private:
int nSides;
int value;

};

#endif
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Link260025-May-03 20:30
Link260025-May-03 20:30 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Rage25-May-03 22:51
professionalRage25-May-03 22:51 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Link260025-May-03 23:11
Link260025-May-03 23:11 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Rage25-May-03 23:34
professionalRage25-May-03 23:34 
GeneralRe: Will the professional programmers please help me here with my DieClass? Pin
Link260026-May-03 0:17
Link260026-May-03 0:17 
Generalwebbrowser Pin
imajit25-May-03 19:12
imajit25-May-03 19:12 
GeneralWeb Crawler or Web Spider Books Pin
Steve ParmIey25-May-03 17:42
Steve ParmIey25-May-03 17:42 
Generalwebbrowser Pin
imajit25-May-03 17:39
imajit25-May-03 17:39 
GeneralRe: webbrowser Pin
Michael Dunn25-May-03 19:06
sitebuilderMichael Dunn25-May-03 19:06 
Generalmfc and &quot;switch&quot; statements Pin
shanila25-May-03 16:52
shanila25-May-03 16:52 
GeneralRe: mfc and &quot;switch&quot; statements Pin
John R. Shaw26-May-03 10:55
John R. Shaw26-May-03 10:55 
GeneralMFC dialog enigma Pin
Beer25-May-03 16:08
Beer25-May-03 16:08 
QuestionHow do I check for stack oevrflow in recursive functions Pin
Rahul Singh25-May-03 15:09
Rahul Singh25-May-03 15:09 
AnswerRe: How do I check for stack oevrflow in recursive functions Pin
ZoogieZork25-May-03 16:55
ZoogieZork25-May-03 16:55 
GeneralRe: How do I check for stack oevrflow in recursive functions Pin
Neville Franks25-May-03 23:34
Neville Franks25-May-03 23:34 
AnswerRe: How do I check for stack oevrflow in recursive functions Pin
John R. Shaw26-May-03 11:11
John R. Shaw26-May-03 11:11 
QuestionHow do I make a pie chart in MFC?? Pin
IrishSonic25-May-03 13:39
IrishSonic25-May-03 13:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.