|
well, apparently something was wrong with that computer. I was working with it at school and now that I am home, the program works fine.
Makes me feel really stupid.... worked 4 hours on that thing and the problem was with the computer. i didn't get anything done....
|
|
|
|
|
Post ere more info about the unhandled exception (the debugger helps a lot, see for instance the call stack window).
BTW you didn't post the Goldfish class code.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the debuggers shows me this window and shows me where it stops...
LeadUp1:
and edx,ecx ;U - trailing byte count
mov al,[esi] ;V - get first byte from source
it stops here
-> mov [edi],al ;U - write second byte to destination
mov al,[esi+1] ;V - get second byte from source
mov [edi+1],al ;U - write second byte to destination
mov al,[esi+2] ;V - get third byte from source
it compiles it fine, but once it executes it I get the
Unhandled exception at 0x1026edac (msvcr90d.dll) in Zoo.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd
|
|
|
|
|
|
I modified my origional post. Its all up there
|
|
|
|
|
Your code is working fine on my system, however I had to do the following modifications, in order to compile it:
Commented out few lines (I haven't all your animal classes ), hence
int main(int argc,char* argv[])
{
Animals *ourAnimals[6];
Animals *goldfish = new Goldfish();
ourAnimals[0]=goldfish;
string name, gender, weight;
name = "the Goldfish";
gender = "Female";
weight = "One Ounce";
goldfish -> setName(name);
goldfish -> setGender(gender);
goldfish -> setWeight(weight);
}
Added the constructor and destructor for the Animals (misname? Wouldn't be better 'Animal'?) class:
class Animals
{
public:
Animals(void){};
virtual ~Animals(void){};
Again and again: use the debugger and have a look at the call stack window.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
noticed (with some help from inside sources) that in the problem is with the compiler for some odd reason it doesn't like creating a 3rd variable of string in Animals.
I moved weight be to be first and name was last (3rd) then it showed Bad ptr message in the debugger.
its a very strange error....
|
|
|
|
|
Sivyo wrote: In main() you have
goldfish -> setName(name);
but in class Animals you have
string setName(string &name){return m_name = name;}
I think your setName() definition should read:
string setName(string name){return m_name = name;}
Also as mentioned previously there is little to be gained in the setXXX() functions in returning the parameter values. Using void return types is better as:
void setName(string name)
{
m_name = name;
}
|
|
|
|
|
I think there's nothing wrong in his method signature.
Why should he pass the string by value?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes, the old brain only working on one cylinder...confusing string with char*.
|
|
|
|
|
noticed when moving around the protected names...
protected:
string m_weight;
string m_name;
string m_gender;
the problem moves to gender. ect...
very very strange
|
|
|
|
|
Even stranger ... I have copied your code, compiled and run it and it works perfectly! May I suggest the extracts you have posted lack some information relevant to the problem.
|
|
|
|
|
|
What do you mean by lock?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Send the EM_SETREADONLY [^] message to the edit box.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How to create an HBITMAP from a window's HDC?
|
|
|
|
|
CreateCompatibleBitmap [^].
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
NO, I want that it is like the LoadBitmap function.
|
|
|
|
|
vcguileaner wrote: NO, I want that it is like the LoadBitmap function.
What do you mean? Do you want to copy the window client area to a bitmap?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
See, for instance, here [^].
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i want to get an HBITMAP like LoadBitmap function.
|
|
|
|
|
Well, the sample code in the link I provided, shows how to.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
it writes an image file rather than returns an HBITMAP.
|
|
|
|
|
What a lazy guy you are: if you stop copying from the sample code just before the following lines
GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen);
Then you have your requested HBTIMAP and no more.
BTW: The image file was for free
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|