I've fixed all of them but still the same. Calling clrscr() in or outside constructor will make no different.fieldofcows wrote: 1) Your constructor does not seem to call clrscr() like you mentioned in your post.
2) The vram variable is set to 0x8B00. Shouldn't this be 0xB8000?
Does the screen clear correctly if you call clrscr() after your class is constructed, i.e. outside of the constructor?
Constructors not called ???
Re: Constructors not called ???
"Programmers are tools for converting caffeine into code."
Re: Constructors not called ???
Gone unsolved ?
Should I fall back to C ? ( Need your suggestions )
Should I fall back to C ? ( Need your suggestions )
"Programmers are tools for converting caffeine into code."
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Constructors not called ???
You have checked out the C++ Bare Bones, haven't you? I would assume all you need is in there. That and the C++ article.
Re: Constructors not called ???
I must scout that page before starting. I think there must be some bugs.Troy Martin wrote:You have checked out the C++ Bare Bones, haven't you? I would assume all you need is in there. That and the C++ article.
"Programmers are tools for converting caffeine into code."
-
- Posts: 4
- Joined: Tue Dec 09, 2008 5:34 pm
Re: Constructors not called ???
Yes, there are a few bugs in the code. One that may be a cause of confusion is that your clrscr() function seems to actually scroll the screen up a line.quanganht wrote:I must scout that page before starting. I think there must be some bugs.
Should this code:
Code: Select all
vram[i] = vram[i+80];
Code: Select all
vram[i] = blank
Re: Constructors not called ???
Thanks for your help but it just doesn't make any difference.
Notice in the source I attached in this post: I've added a init() fuction which acts like the constructor, then I call it. After that, the clrscr() works fine, but not for write() or put().
Notice in the source I attached in this post: I've added a init() fuction which acts like the constructor, then I call it. After that, the clrscr() works fine, but not for write() or put().
- Attachments
-
- src.rar
- (5.34 KiB) Downloaded 38 times
"Programmers are tools for converting caffeine into code."
Re: Constructors not called ???
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
The man who walks alone is likely to find himself in places
no one has ever been before.
Re: Constructors not called ???
Have seen it several times before. Trying but don't sure it will help. Thanks anyway
"Programmers are tools for converting caffeine into code."
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Constructors not called ???
You're on the right track now. You must test your console functions before you try to put them in a class. Otherwise you've got no idea whether or not they actually work!Notice in the source I attached in this post: I've added a init() fuction which acts like the constructor, then I call it. After that, the clrscr() works fine, but not for write() or put().
Re: Constructors not called ???
Ok. /me confused. And when I'm confused, I take a step back and summarize.
1) You do not need any support code, standard library or otherwise, to have member object constructors called.
2) You do need support code in your loader assembly to have the constructors of any global objects called. I would guess this is also true for static member objects, but I haven't checked that. Bare Bones C++ and other sources show how to do this.
3) You do need support code to use "new".
4) You must check any functionality "outside the box" before you use it as an indicator for saying other things don't work. (Printing a character, clearing the screen etc.)
With all due respect, but I think those 4 points should solve quanganht's problem...
1) You do not need any support code, standard library or otherwise, to have member object constructors called.
2) You do need support code in your loader assembly to have the constructors of any global objects called. I would guess this is also true for static member objects, but I haven't checked that. Bare Bones C++ and other sources show how to do this.
3) You do need support code to use "new".
4) You must check any functionality "outside the box" before you use it as an indicator for saying other things don't work. (Printing a character, clearing the screen etc.)
With all due respect, but I think those 4 points should solve quanganht's problem...
Every good solution is obvious once you've found it.
Re: Constructors not called ???
After quite a while strugling, the code suddenly worked!( although '\n' did perormed right )
And I don't even understand what happened. I guess there is bugs inside put(), because when I rewrite it, "Hello world!" can be seen.
If anyone can find what's wrong with '\n', thanks!
And I don't even understand what happened. I guess there is bugs inside put(), because when I rewrite it, "Hello world!" can be seen.
If anyone can find what's wrong with '\n', thanks!
- Attachments
-
- src.rar
- (5.51 KiB) Downloaded 62 times
"Programmers are tools for converting caffeine into code."
Re: Constructors not called ???
Constructors are always called when an object is created on the stack.
For global objects you need to call the constructor yourself
either you use the way JamesM pointed out or you do
For global objects you need to call the constructor yourself
either you use the way JamesM pointed out or you do
Code: Select all
CConsole console;
void kmain() { console.CConsole(); }
Re: Constructors not called ???
Thats not a good idea as we already have a way to call all the global objects' constructors at start up.cyr1x wrote:Constructors are always called when an object is created on the stack.
For global objects you need to call the constructor yourself
either you use the way JamesM pointed out or you doCode: Select all
CConsole console; void kmain() { console.CConsole(); }
"Programmers are tools for converting caffeine into code."
Re: Constructors not called ???
I never said that this was a good idea, I only said that it's possibly to do it that way.
Re: Constructors not called ???
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
The man who walks alone is likely to find himself in places
no one has ever been before.