BAsic Kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Locked
dannyboy997
Posts: 4
Joined: Fri Jun 19, 2009 11:34 am
Location: edmonton
Contact:

BAsic Kernel

Post by dannyboy997 »

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!!!!!!!!! :D :D :D :D :D :D

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
pcmattman
Member
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

Post by pcmattman »

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...

Code: Select all

Video();
Video();
You do know C++, right?
dannyboy997
Posts: 4
Joined: Fri Jun 19, 2009 11:34 am
Location: edmonton
Contact:

Re: BAsic Kernel

Post by dannyboy997 »

well yeh !!

and if i take out one off them it gives me some other errors!!
pcmattman
Member
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

Post by pcmattman »

If you really knew C++ you'd know exactly why your code doesn't work.
User avatar
alethiophile
Member
Member
Posts: 90
Joined: Sat May 30, 2009 10:28 am

Re: BAsic Kernel

Post by alethiophile »

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.
dannyboy997
Posts: 4
Joined: Fri Jun 19, 2009 11:34 am
Location: edmonton
Contact:

Re: BAsic Kernel

Post by dannyboy997 »

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
pcmattman
Member
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

Post by pcmattman »

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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: BAsic Kernel

Post by Solar »

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.
Every good solution is obvious once you've found it.
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: BAsic Kernel

Post by kop99 »

You should better read following page.
http://forum.osdev.org/viewtopic.php?f=1&t=16944
User avatar
Combuster
Member
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

Post by Combuster »

Seconded, thread locked
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Locked