Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Abstact types

This topic is 6725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a simple questions if anyone can help. Here they are: 1) Can someone explain what a abstract data types are and what abstact base class are. If there is such a thing, what is a abstract function? What is the difference between a abstract class and a normal class which I think is called a concrete class? 2) Why is it you can''t do void function(int a[][9]) {} main() { int a[10][9]; function(a); } you have to do it like this void function(int a[][9]) {} main() { int a[10][9]; function(a); } but you can do this void function(int *) {} main() { int a[10]; function(a); } 3)What''s the difference between private and protected data types? Thank you all for your help in advance. Braves

Share this post

Link to post
Share on other sites

I''m not sure I see the difference between the first two program-fragments you have given...

As far as abstract classes and functions go, it all has to do with object oriented programming, inheritance, and polymorphism. (Who ever broght that word into use should be shot).

I''m not great at explaining things, but here is an example:

class Reader {
virtual char readChar() = 0; // abstract definition

class MemReader : public Reader {
char readChar() { return *(ptr++); }

class FileReader : public Reader {
char readChar() { return getc(fileStream); }

Here, Reader is an abstract class because it contains an abstract function. What this basically says is that any class derived from Reader MUST implement a version of readChar. Also, because Reader contains an abstract function, it can not be instantiated, because it wouldn''t know what to do if readChar was called. The ''virtual'' modifier in Reader simply says that it is possible for classes derived from Reader to effectively override any functionality that may or may not have been given in the original declaration.

A quick run-down of access modifiers: (And I mean quick)...

''public'' means that the field/function can be accessed from anywhere that the object can.
''protected'' means that only functions declared as either part of the class or any class derived from the original class have access.
''private'' means that only functions declared in that object have access rights.

Hope that helped. I know it confused the hell out of me...

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!