BAsic Kernel
-
- Posts: 4
- Joined: Fri Jun 19, 2009 11:34 am
- Location: edmonton
- Contact:
BAsic Kernel
Well i followed this tutorial : http://74.125.155.132/custom?q=cache:d4 ... 1971271392
it's also a pdf..
but i get these errors when compiling kernel.cpp to kernel.o using the g++ compiler
error:
=============================
In file included from Kernel.cpp:1:
Video.h:8: error: ‘Video::Video()’ cannot be overloaded
Video.h:7: error: with ‘Video::Video()’
=============================
this is my code :
Kernel.cpp
=============================
#include "Video.h"
int main(void)
{
Video vid;
vid.write("Hello, world!");
}
============================
Video.h
============================
#ifndef VIDEO_H
#define VIDEO_H
class Video
{
public:
Video();
Video();
void clear() ;
void write(const char *cp) ;
void put(const char c) ;
private:
unsigned short *videomem ; //pointer to video memory
unsigned int off ; //offset, used like a y cord
unsigned int pos ; //position, used like x cord
}; //don't forget the semicolon!
#endif
===========================
Video.cpp
===========================
#include "Video.h"
Video::Video()
{
pos=0 ; off=0 ;
videomem = (unsigned short*) 0xb8000 ;
}
Video::Video()
void Video::clear()
{
unsigned int i;
for(i=0; i<(80*25); i++)
{
videomem = (unsigned const char) ' ' | 0x0700 ;
}
pos=0 ; off=0 ;
}
void Video::write(const char *cp)
{
const char *str = cp, *ch;
for (ch = str; *ch; ch++)
{
put(*ch) ;
}
}
void Video::put(char c)
{
if(pos>=80)
{
pos=0 ;
off += 80 ;
}
if(off>=(80*25))
{
clear() ;
clear
}
videomem[off + pos] = (unsigned const char) c | 0x0700 ;
pos++ ;
}
==============================
Please Help Thanks!!!!!!!!!
website : http://qwiic.homelinux.com
it's also a pdf..
but i get these errors when compiling kernel.cpp to kernel.o using the g++ compiler
error:
=============================
In file included from Kernel.cpp:1:
Video.h:8: error: ‘Video::Video()’ cannot be overloaded
Video.h:7: error: with ‘Video::Video()’
=============================
this is my code :
Kernel.cpp
=============================
#include "Video.h"
int main(void)
{
Video vid;
vid.write("Hello, world!");
}
============================
Video.h
============================
#ifndef VIDEO_H
#define VIDEO_H
class Video
{
public:
Video();
Video();
void clear() ;
void write(const char *cp) ;
void put(const char c) ;
private:
unsigned short *videomem ; //pointer to video memory
unsigned int off ; //offset, used like a y cord
unsigned int pos ; //position, used like x cord
}; //don't forget the semicolon!
#endif
===========================
Video.cpp
===========================
#include "Video.h"
Video::Video()
{
pos=0 ; off=0 ;
videomem = (unsigned short*) 0xb8000 ;
}
Video::Video()
void Video::clear()
{
unsigned int i;
for(i=0; i<(80*25); i++)
{
videomem = (unsigned const char) ' ' | 0x0700 ;
}
pos=0 ; off=0 ;
}
void Video::write(const char *cp)
{
const char *str = cp, *ch;
for (ch = str; *ch; ch++)
{
put(*ch) ;
}
}
void Video::put(char c)
{
if(pos>=80)
{
pos=0 ;
off += 80 ;
}
if(off>=(80*25))
{
clear() ;
clear
}
videomem[off + pos] = (unsigned const char) c | 0x0700 ;
pos++ ;
}
==============================
Please Help Thanks!!!!!!!!!
website : http://qwiic.homelinux.com
Last edited by 01000101 on Fri Jul 10, 2009 10:13 pm, edited 1 time in total.
Reason: Removed email address
Reason: Removed email address
-
- 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: BAsic Kernel
Hi,
First, please use the code tags and avoid using colours. Some of us are using dark themes which makes your post hard to read. As for your problem...
First, please use the code tags and avoid using colours. Some of us are using dark themes which makes your post hard to read. As for your problem...
You do know C++, right?Code: Select all
Video(); Video();
-
- Posts: 4
- Joined: Fri Jun 19, 2009 11:34 am
- Location: edmonton
- Contact:
Re: BAsic Kernel
well yeh !!
and if i take out one off them it gives me some other errors!!
and if i take out one off them it gives me some other errors!!
-
- 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: BAsic Kernel
If you really knew C++ you'd know exactly why your code doesn't work.
- alethiophile
- Member
- Posts: 90
- Joined: Sat May 30, 2009 10:28 am
Re: BAsic Kernel
If you're trying to declare a destructor as well as a constructor for Video(), then you want a tilde (~) in front of the second one, and in video.cpp as well.
If I had an OS, there would be a link here.
-
- Posts: 4
- Joined: Fri Jun 19, 2009 11:34 am
- Location: edmonton
- Contact:
Re: BAsic Kernel
well i found the problem because the tutorial was originaly made in a pdf but i could not view that file, so i tried the html version but then i saw that it was generated by google accordingly to the pdf but left out multiple parts so then i tryed it on another computer and i found the misstakes that google made ...
thanks for the help
thanks for the help
-
- 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: BAsic Kernel
Even so, you should have been able to fix the bugs. There's two problems with your posted code, and if you know C++ well enough to be thinking about writing an operating system with it, you will know what they are, and how to fix them.
Re: BAsic Kernel
If you copy & paste code from the web, I think your effort is doomed from the start.
If you follow tutorials, never copy & paste. Type it in. This gives you those crucial seconds to think about the code. The errors should have been obvious then.
If you follow tutorials, never copy & paste. Type it in. This gives you those crucial seconds to think about the code. The errors should have been obvious then.
Every good solution is obvious once you've found it.
Re: BAsic Kernel
You should better read following page.
http://forum.osdev.org/viewtopic.php?f=1&t=16944
http://forum.osdev.org/viewtopic.php?f=1&t=16944
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: BAsic Kernel
Seconded, thread locked