|
You could search here on CP for "record sound" for some source code.
Mark
|
|
|
|
|
hello,
pls find me out why code is not work for solitaire game...
Thanks in advance.pls..
here is code:
#include<iostream>
using namespace std;
/*****CLASS PLAYING CARD*****/
class PlayingCard
{
private:
int rank;//integer 1-13
int suit;//integer0-3
char color;//red('r') or black('b')
public:
PlayingCard(int,int);
PlayingCard();
void display();
~PlayingCard();
const static int diamond;
const static int heart;
const static int spade;
const static int club;
};
/***** CLASS MAKING PILE OF CARDS*****/
class PileofCards
{
private:
PlayingCard *pile;//pointer to array of playing cards
int top;//last element added to array
int size;//no. of cards in pile
int position;//position of pile amongst others
public:
PileofCards(int,int);
~PileofCards();
PlayingCard Peek();
PlayingCard Remove();
void display();
void Add(PlayingCard);
bool IsEmpty();
bool IsFull();
};
/***** CLASS DECK OF CARDS*****/
class Deck
{
private:
PlayingCard *deck[52];
int size;
public:
Deck();
int getSize();
bool IsEmpty();
PlayingCard getCard(int i);
void Display();
PlayingCard removeCard(int i);
~Deck();
};
/*****CLASS SOLITIRE*****/
class Solitire{
private:
Deck deckofCards;
PileofCards shuffled;
public:
Solitire();
void shuffle();
void display();
};
Solitire::Solitire():shuffled(52,1)
{}
/*****INITIALIZING*****/
const int PlayingCard::diamond=0;
const int PlayingCard::heart=1;
const int PlayingCard::spade=2;
const int PlayingCard::club=3;
/*****CONSTRUCTOR PLAYING CARD*****/
PlayingCard::PlayingCard(int X,int Y)
{
rank=X;
suit=Y;
if(Y==0 || Y==1)
{
color='r';
}
else if(Y==2 || Y==3)
{
color='b';
}
else
{
cout<<"invalid suit,object not created"<<endl;
}
}
*****constructor="" overloaded*****=""
playingcard::playingcard()
{
}
="" *****destructor*****=""
playingcard::~playingcard()
{
}
="" pile="" of="" cards*****=""
pileofcards::pileofcards(int="" x,int="" y)
{
size="X;
position=Y;
pile=" new="" playingcard[size];
top="-1;//empty" array
}
=""
pileofcards::~pileofcards()
{
delete="" []="" pile;
}
="" *****is="" empty*****=""
bool="" pileofcards::isempty()
{
if(top="=-1)
{
cout<<"pile" empty"<<endl;
return="" true;
}
else
{
return="" false;
}
}
="" full*****="" pileofcards::isfull()
{
if(top="=size-1)
{
cout<<"sorry" cannot="" add="" since="" is="" full"<<endl;
return="" true;
}
else=""
{
return="" false;
}
}
="" *****adding="" playing="" card="" to="" the="" pile*****=""
void="" pileofcards::add(playingcard="" x)
{
if(!isfull())
{
pile[top+1]="X;
top++;
}
}
/*****REMOVING" from=""
playingcard="" pileofcards::remove()
{
if(!isempty())
{
top--;
}
return="" pile[top+1];
}
="" *****peeking="" top="" pileofcards::peek()
{
return="" [top];
}
="" *****display....playing="" card*****="" playingcard::display()
{
cout<<rank<<"="" "<<suit<<"="" "<<color<<endl;
}
="" deck*****=""
deck::deck()
{=""
int="" j="0;
for(int" i="1;i<=13;i++)
{
deck[j]=new" playingcard(i,playingcard::spade);
j++;
}
for(int="" k="1;k<=13;k++)
{
deck[j]=new" playingcard(k,playingcard::diamond);
j++;
}
for(int="" l="1;l<=13;l++)
{
deck[j]=new" playingcard(l,playingcard::heart);
j++;
}
for(int="" m="1;m<=13;m++)
{
deck[j]=new" playingcard(m,playingcard::club);
j++;
}
int="" size="52;
}
/*****DESTRUCTOR"
deck::~deck()
{
if(!isempty())
{
for(int="" deck[i];
}
}
}
else=""
{
delete="" deck;
}
}
="" *****get="" size*****="" deck::getsize()
{
return="" size;
}
="" empty....deck*****="" deck::isempty()
{
if(getsize()="=0)
{
return"
return="" false;
}
="" *****getcard*****="" deck::getcard(int="" j)
{
return="" *deck[j];
}
="" *****display....deck*****="" deck:display()
{
for(int="">display();
}
}
/*****REMOVE...DECK*****/
PlayingCard Deck::removeCard(int i)
{
PlayingCard temp;
temp=getCard(i);
delete deck[i];
if(!IsEmpty())
{
for(int j=i;j<size;j++)
{
deck[j]=deck[j+1];
}
}
size--;
return temp;
}
="" *****shuffle*****=""
void="" solitire::shuffle()
{
int="" i;=""
while="" (!deckofcards.isempty())
{
i="rand()%deckofCards.getSize();"
="" cout<<"remove="" card="" \n";
shuffled.add(deckofcards.removecard(i));
}
}
="" *****display...solitire*****="" solitire::display()
{
if(!shuffled.isempty())
{
shuffled.display();
}
}
="" *****display...pile="" of="" cards*****="" pileofcards::display()
{=""
int="" i="0;
while(i<=top)
{
pile-">display();
i++;
pile++;
}
cout<
|
|
|
|
|
|
Sorry for that.. Thanks for remind me..
when I ran that code .. I got three error.. might be it from Deck..
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 2 error C2063: 'Deck::deck' : not a function
Warning 3 warning C4154: deletion of an array expression; conversion to pointer supplied
|
|
|
|
|
Now everything is ok!No error anymore and I can run the program.
But it not work coz of warning.And if I debug the program,it said "Debug Assertion Failed!"and with "Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)"
Here is part of code:
[pre]Deck::~Deck()
{
if(!IsEmpty())
{
for(int i=0;i
|
|
|
|
|
|
I think error comes from destructor..mean warning!
Deck::~Deck()
{
if(!IsEmpty())
{
for(int i=0;i{
if(deck[i]!=NULL)
{
delete deck[i];
}
}
}
else
{
Code:
delete [] deck;
}
}
|
|
|
|
|
Hi,
with the help of MSDN I wrote my own little (pure) Windows Service, that doesn't do anything. I also implemented the ability to install/uninstall this service in the service database. My problem now is, that if I want to start that service from the system control in windows it crashes with a well known error message like this: "The instruction at 0xnnnnnnn referenced memory at 0xnnnnnnn. The memory could not be written."
I then wrote a simple logging-function, which prints the status information about my service to a file. And when I look at this file it seems that all is correct. All things are initialized and so on. And I also get to that point where the service's main function takes place, that means I get to the point where the real work of the service should take place. But as I said before, the service crashes while trying to start it up. That's a little strange to me. Maybe someone encountered a similar problem before or can give me some hint or help. That would be very nice. I know this description is a little bit vague, but it's not that easy because I can't figure out WHERE my service crashes. That's in fact my problem
Ah I forgot to mention, that I am using WinXP. Maybe that's important...
|
|
|
|
|
maybe posting your code will help...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
You can debug your service, and this is the best way to understand what happens.
Install the service with own process and interact with desktop, then place somwehere in code (in control dispatcher, or even service main) a DebugBreak call.
Go in admin tools/services, start the service; when the service will hit the DebugBreak call will invoke debugger, and you have now the chance to enter in Visual C++ debugger and check step by step the troubled piece of code.
|
|
|
|
|
Mh... I made a new project for my windows service and placed my real application code in there, and what shall I say.. it works perfectly. I just made some refactorings to my original windows service code... don't know why it works now. Anyway thank you for your help. I will remember that tip with the debugging.
|
|
|
|
|
When I use this control (AMSCurrencyEdit for example) I don't see the dialog from the class view and intellisense in that dialog.
The project compiles and builds OK, but i´d like to have intellisense in that dialogs.
Any solution for that?
it´s the journey, not the destination that matters
|
|
|
|
|
The intellisense is not very safe... some times it disappears.
First of all copy the entire folder of the project as a backup.
If I do not remember it bad, you should close Visual Studio, delete the .clw file and then try to reopen that project and try to go to the class wizard, as it will fail to locate that file, then you'll be asked to generate it again.
Select all the files in that project again and then try it. The intellisense should work.
PS: I've been a lot of time without touching the Visual C++ environment so this is from some rusty place in my brain... please remember to make the backup previously.
Hope this helps.
|
|
|
|
|
Thanks for your fast response!!!!
Unfortunately, I'm using VS2005. There's no .clw file.
And the problem is exactly with that component.
I change the name from CAMSCurrencyEdit to CEdit, save the project, and the dialog appears in class view, I change it again to CEdit and it dissapears.
It's not a big deal, but it's annoying.
it´s the journey, not the destination that matters
|
|
|
|
|
uuups... sorry, I'm beginning to be a dinosaur... I hope to be able to switch to VS2005 this year 2007...
ErnestoNet wrote: It's not a big deal, but it's annoying.
It always becomes annoying...
Well, I hope that somebody that will know better than me the VS2005 environment will be able to help you soon.
Good luck.
|
|
|
|
|
hi i m using this code i on windows XP and visual studio 6,i receive error mentioned above
i had include these two lines as well,in stdaxh.h
#define _WIN32_WINNT 0x0500
#include <windows.h>
the code is below
<br />
MENUITEMINFO mii; <br />
memset(&mii, 0, sizeof(MENUITEMINFO));<br />
mii.cbSize = sizeof(MENUITEMINFO);<br />
mii.fMask = MIIM_ID| MIIM_BITMAP |MIIM_DAMFT_BITMAPTA; <br />
error is describled as below
D:\_RCProj\_VC6\live desktop\Source code\WinScreenAnotator.cpp(684) : error C2065: 'MIIM_BITMAP' : undeclared identifier
D:\_RCProj\_VC6\live desktop\Source code\WinScreenAnotator.cpp(684) : error C2065: 'MIIM_DAMFT_BITMAPTA' : undeclared identifier
Error executing cl.exe.
Creating browse info file...
WinScreenAnnotatorVC6.exe - 2 error(s), 0 warning(s)
Regards.
Tasleem Arif
|
|
|
|
|
well, MIIM_BITMAP is not defined in old versions of the winuser.h header file (maybe you'll need a Visula Studio service Pack, I'm not sure). On the other hand, I cannot find any reference to MIIM_DAMFT_BITMAP inside MSDN online, where did you get it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
It seems you need to include header file for 'MIIM_DAMFT_BITMAPTA'
|
|
|
|
|
Hi All
I have miles of old code that looks like this:
CString csString = "hello World";
Having just installed VS2005, I get the error:
'initializing' : cannot convert from 'const char [3]' to 'ATL::CStringT<basetype,stringtraits>
I know that I can get around this like this:
CString csString = _T("Hello World");
But want to know if there is a single switch somewhere that will let my code compile as it was?
I also don't understand why it's using ATL and not MFC - I craeted a new MFC project
Many thanks for any help offered
|
|
|
|
|
John Strudwick wrote: if there is a single switch somewhere that will let my code compile as it was?
Possibly; it sounds like you're set up for a UNICODE build. Take a look at your stdafx.h file. If the symbol UNICODE is #define 'd, try commenting it out and rebuilding the solution.
John Strudwick wrote: I also don't understand why it's using ATL and not MFC - I craeted a new MFC project
Back in MFC 7.0 (Visual Studio 2002) they switched from separate CString implementations within ATL and MFC to a single, common implementation. As part of that, they improved the type-safety of the various constructors and assignment operators.
Software Zen: delete this;
|
|
|
|
|
Thanks Gary - that has solved the problem
I went into the properties dialog and changed from unicode to not set - works a treat
Thanks again
|
|
|
|
|
You're welcome. I believe I remember reading that the wizards in VS2005 changed from a default of building ANSI applications to UNICODE.
Believe it or not, there are advantages to building apps as UNICODE. They are much easier to translate to other languages (which may not be a concern for you). They also have something of a performance advantage. Windows itself uses UNICODE. With ANSI applications, there is an implicit conversion from ANSI strings to UNICODE with strings you pass to Windows, and the reverse when Windows returns strings to you.
Software Zen: delete this;
|
|
|
|
|
and where should I call it?
Hello all,
in the PostNCDestroy overriden function of the main dialog I want to kill the timer that is running there, I'm calling something as simple as KillTimer(0); and this should work, but it makes the entire application to close suddenly.
Any idea?
Thank you in advance.
|
|
|
|
|
PostNcDestroy() is called after the corresponding window has been destroyed, which is why the KillTimer is failing. You don't need to call KillTimer in this case, because the window destruction takes care of it for you.
Software Zen: delete this;
|
|
|
|
|
Thank you, I'll remove that commented line now.
|
|
|
|