|
kerthy_29 wrote: I want to make the class Account work in C++.
Ok, so what is an account (object)? What are its properties? What can you tell it (settor methods)? What can it tell you about itself (getter methods). Knowing this will go a long way towards designing the class.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I understand some of that. This is what I have figured out so far, but I don't know if it would work when I add it to the code I already have done. Does this look right?
<br />
class Account {<br />
int AccountBalance;<br />
};<br />
class Deposit{<br />
int AccountBalance, amount;<br />
public:<br />
void set_values(int, int);<br />
int dep () {return (AccountBalance+amount);}<br />
}; <br />
class Withdraw{<br />
int AccountBalance, amount;<br />
public:<br />
void set_values(int, int);<br />
int wit () {return (AccountBalance-amount);} <br />
};
Thanks for the help.
Elaine
|
|
|
|
|
Account seems about right. It's a noun, so a class is appropriate. However, Deposit and Withdraw are verbs. This indicates that they should be operations rather than classes.
What do you think about this design: (I will let you fill in the code.. it's your assignment! )
class Account {
int balance;
public:
void Deposit(int amount)
{
}
void Withdraw(int amount)
{
}
void SetBalance(int balance)
{
}
int CurrentBalance()
{
}
}; I made the operations part of the Account class. In an enterprise class design, this should be designed a bit differently. But let's not shoot over the target - the aim is to learn the C++ language, right? I also added SetBalance and CurrentBalance so that client code (fancy name for code which uses objects of a class), can initialize the object and inspect the object.
I would like to know how you reasoned when you made your design. Don't see this is as criticism. If there's one thing I've learned during the years, is that if you try to explain your own design in human language, the design mistakes will be very easy (or at least easier) to spot. The golden rule is that if it doesn't make sense in a human language, it won't make sense in a programming language.
--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören
|
|
|
|
|
Thanks for pointing out some fixes. I got the original coding from the python coding that I had already done and knew that it worked.
Elaine
|
|
|
|
|
After inspection of your original python code, it would seem that you are already familiar with my proposed design.. Sorry about that.
--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören
|
|
|
|
|
I wouldnt be sorry about it Joergen - you put her back on the tracks with her understanding of what it could/should look like in c++ - when I looked at her suggestion I thought 'yuck', transliteration of Python or not
At least unlike other people's homework attempts, she's made an effort, which is rare enough these days, so good-on-ya
'g'
|
|
|
|
|
I have an existing DLL named as A1.dll ,which is a MFC dll .
I added a configuration that renames the output of the same as B1.dll
hence it generates b1.lib
In my application i used to link with A1.lib which I replaced with B1.lib and I copied B1.dll to the executable folder .
Now when i run it , i get an error saying that A1.dll is missing .
Where do i specify this dependency ?
Engineering is the effort !
|
|
|
|
|
|
act_x wrote: A1.lib which I replaced with B1.lib
Probably, you have not removed A1.lib, from linking options.
|
|
|
|
|
I want to create a software that will produce almost all types of BANNERS(static and animated).So, is Visual C++/MFC a better approach for this one or should I go with VB.net?........
|
|
|
|
|
|
|
If you have to ask a question like that, and word it like that, I would suggest going with whatever one has the easiest-to-use graphic library, to lessen the chance of breaking something. (I would guess that VB.Net would be the safest choice for you.)
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
McDonalds makes a Fish Filet
led mike
|
|
|
|
|
|
I still like that, I have developed it into a statement... waiting for the next appropriate VB Lounge thread to unleash it.
led mike
|
|
|
|
|
Some days there's a ton of 'em in a row....and when reading through your replies I think
it's like your picking them up in a bus for their one way ride to McDs! LOL
|
|
|
|
|
I'm using VC++ 6.0 and I can't figure out how to find the location of the virtual store in Vista. Everything works okay until I call a shell command to open a file. Any thoughts or suggestions would be appreciated!
Will
|
|
|
|
|
What is the "virtual store"?
|
|
|
|
|
I believe it's a folder under the %userprofile%\AppData\Local\ folder.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Can you CreateCompatibleDC/Bitmap from a printer DC?
I'm trying to write out what i print as a .BMP file
But all i get is a big black bitmap...
Any ideers?
...Steve
(_hdc below is the printer DC and has already been drawn on
fn is the .bmp filename and w,h are the size of the _hdc)
Oops - debugging output here:
fn=c:\test_00.bmp w=6400 h=4900
Canvas::SaveBmp bgn
got bitblt
got di bitmap
got bm
got bmi
got size=94080000
alloc'd n got bits
writin file
cleanup
Canvas::SaveBmp end
HDC mCnv;
if ((mCnv = ::CreateCompatibleDC (_hdc)) == NULL)
Die ("Canvas::SaveBmp CreateCompatibleDC");
HBITMAP mBmp, pBmp;
if ((mBmp = ::CreateCompatibleBitmap (_hdc, w, h)) == NULL)
Die ("Canvas::SaveBmp CreateCompatibleBitmap");
if ((pBmp = (HBITMAP) ::SelectObject (mCnv, mBmp)) == NULL)
Die ("Canvas::SaveBmp SelectObject");
if (::BitBlt (mCnv, 0, 0, w, h, _hdc, 0, 0, SRCCOPY) == FALSE)
Die ("Canvas::SaveBmp BitBlt died");
BITMAP bm;
::GetObject (mBmp, sizeof (bm), (LPVOID) & bm);
DBG(" got bm");
BITMAPINFOHEADER bmi;
MemSet (& bmi, 0, sizeof (bmi));
bmi.biSize = sizeof (bmi);
bmi.biWidth = w;
bmi.biHeight = h;
bmi.biPlanes = 1;
bmi.biBitCount = bm.bmBitsPixel;
bmi.biCompression = BI_RGB;
DBG(" got bmi");
if (! ::GetDIBits (mCnv, mBmp, 0, h, NULL, (BITMAPINFO *)(& bmi),
DIB_RGB_COLORS))
Die ("Canvas::SaveBmp GetDIBits died");
if (bmi.biSizeImage == 0)
Die ("Canvas::SaveBmp GetDIBits - no size");
sprintf(dbg," got size=%d", bmi.biSizeImage);DBG(dbg);
char *bits = new char [bmi.biSizeImage];
if (! ::GetDIBits (mCnv, mBmp, 0, h, bits, (BITMAPINFO *)(& bmi),
DIB_RGB_COLORS))
Die ("Canvas::SaveBmp GetDIBits(2) died");
DBG(" alloc'd n got bits");
BITMAPFILEHEADER bmf;
MemSet (& bmf, 0, sizeof (bmf));
bmf.bfType = ((WORD) 'B' | ('M' << 8));
bmf.bfSize = sizeof (bmf) + sizeof (bmi) + bmi.biSizeImage;
bmf.bfOffBits = sizeof (bmi);
File f;
if (f.Open (fn, "w")) {
DBG(" writin file");
f.Put (& bmf, sizeof (bmf));
f.Put (& bmi, sizeof (bmi));
f.Put (bits, bmi.biSizeImage);
f.Shut ();
}
DBG(" cleanup");
delete [] bits;
::SelectObject (mCnv, pBmp);
::DeleteObject ( mBmp);
::DeleteDC (mCnv);
DBG("Canvas::SaveBmp end");
|
|
|
|
|
Steve Hazel wrote: fn=c:\test_00.bmp w=6400 h=4900
That is quite a large bitmap. On my machine CreateCompatibleBitmap falls over and GetLastError() returns 0x00000008 - "Not enough storage is available to process this command" when I try to create large bitmaps.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Thanks for checkin' into it - I appreciate that
Yep. I noticed it was biiig, but this machine handles it ok
and I only need the app to work for -me- so I can get this bitmap for my docs.
I wonder how to get around this...
I wonder how the printer driver handles this big of a bitmap?
Keeps it compressed or somethin?
I'd really like to have a full resolution bitmap (or jpg or whatever) for
my docs for this app. (which eventually will just do a regular printpreview)
Anybody got any ideers?
Thanks
...Steve
|
|
|
|
|
Steve Hazel wrote: I'd really like to have a full resolution bitmap (or jpg or whatever) for
my docs for this app. (which eventually will just do a regular printpreview)
This may be a dumb question, but if you have access to the application (and presuming it shows the image on screen), why not just print-screen and extract the necessary image using Paint?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
When my app prints, it uses a different drawing function than when drawing in a window.
(Takes advantage of the higher printer resolution, etc)
We're talkin music printing here, by the way.
On screen, it's a regular piano roll as my docs show here:
http://shazware.com/ditty/12_tinker.html[^]
On the printout, a couple pianorolls are squashed on the page in parallel down the page (as space permits).
Ok, so how can i get that big ole bitmap... But non-black ?
The bitmap file =is= being created, (93 meg!) but it's all black.
The size can be alloc'd - width * height * 3 (bytes for RGB).
So either the BitBlt ain't workin or the GetDIBits() ain't workin...
Hmmm...
Bet it's the GetDIBits runnin outa space...
[edit] nope - the new works so why would GetDIBits need space? [/edit]
Maybe it'll work on my machine at home... I think it's got more ram
...Steve
|
|
|
|