Page 1 of 1

BAsic Kernel

Posted: Fri Jul 10, 2009 8:01 pm
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

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 8:13 pm
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?

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 8:36 pm
by dannyboy997
well yeh !!

and if i take out one off them it gives me some other errors!!

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 8:41 pm
by pcmattman
If you really knew C++ you'd know exactly why your code doesn't work.

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 8:51 pm
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.

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 8:57 pm
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

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 10:11 pm
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.

Re: BAsic Kernel

Posted: Fri Jul 10, 2009 11:51 pm
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.

Re: BAsic Kernel

Posted: Sat Jul 11, 2009 1:45 am
by kop99
You should better read following page.
http://forum.osdev.org/viewtopic.php?f=1&t=16944

Re: BAsic Kernel

Posted: Sat Jul 11, 2009 3:34 am
by Combuster
Seconded, thread locked