This is just an example, of course it is incomplete, you must code whatever you need in your video driver

Code: Select all
class VideoDriver implements Driver {
static private VideoDriver driver=null;
static public VideoDriver getDriver() {
if (driver==null) driver=new VideoDriver();
return driver;
}
private VideoDriver() {
// initialization & stuff
}
}
No, C++ will not let you declare the constructor as private.I have a question:
can I do the getdriver() thing in C++??
You can merely instantiate it. Your variable will be just a regular offset within your data section.and if I use the constructor in C++ does the object load in a diff place in the program??? I mean it loads as opposed of just getting the address of the original not instance class...
Yes, you get separated offsets in memory of every object you instantiate. This is the core of OOP programming.now just using a constructor in C++ means doing it statically, right?? That means every time I make an instance it copys itself in memory again???
It's up to you. If you have the memory manager up & running (like you should be if you're gonna mess with objectsand dynamically would be what??
dynamically in C++ is using the new and delete operators and accessing the data and procedures with -> instead of . (dot)
static data is "physically" stored in the file, at least its space. dinamic data is when you "new" or "malloc()" memory space.thanks for the info.. if u can explain a bit about the C++ works please.. dynamic vs static... and how they load in memory...
It's up to you. speed vs size.I figgured out that static vs dynamic in C++ is only linktime vs runtime... in terms of making readonly objects etc... putting objs into ROM
now which one whould I use for my os?? really I dont get what the advantages and disadvantages are.. I use static cuz thats what Im used to, but y should I use either one???
thanks
good. watch your foot.Ok, thanks. I think Ill stick to C++ due to my experience and the fact that its faster and the fact that I already think C++ and would help in making bug free code.
well, the static keyword when used in variables inside classes has the same meaning in c++ and java, so that's the same thing.Now, how would I put that java code into C++??
thanks
now basic C is easy to use as a basic procedural language... same logic with assembler like MASM... etc.
So how do I do that in C++?