Thread: classes,,,help!

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    10

    Unhappy classes,,,help!

    hi guys,,,
    before i ask for your help again,,i wanted to thank those of you who answered my last post,,it was a great help.
    this time i was wondering ,,if i have created .h file and .c file classes for different member functions,,can i make another class from these classes by #including them in the new class and then use map ????
    i know i am not very clear so here is a bit of what i am doing,,,,i am trying to create an image class with box ,, line,,point,,,etc,,,,and these box,line,point,,,thingies are in a header file and cc files of their own,,,,so can i just #include them in my image class and then use a map???? bc at the moment its not working ,,,i'll really appreciate ur help,,,sami

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    Sounds more like you want inheritance. Don't know about map.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    10
    thanx for the quick reply,,,,but no i dont think i need inheritance,,,the thing is that i need to put all these functions( they are not specified as classes,,,they are just files) into an image class and then create a map with a key and image such as map(key,image) where key is a string name. ahhh,,,its driving me naguhts,,why cant i figure it out i have no idea but plz help

  4. #4
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    It sounds odd, but maybe I just don't get it.

    If you have a function than you can call it any time from anywhere. If it is a public method and is part of a class and is preceded by an instance of that classes object when it is called. In most cases where there are shared methods inheritance is used, and sometimes the methods are declared virtual if any of them are overridden in the derived class. Maybe show some code.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    Originally posted by sami
    thanx for the quick reply,,,,but no i dont think i need inheritance,,,the thing is that i need to put all these functions( they are not specified as classes,,,they are just files) into an image class and then create a map with a key and image such as map(key,image) where key is a string name. ahhh,,,its driving me naguhts,,why cant i figure it out i have no idea but plz help
    Well, if you're not using classes, why the subject heading? Anyway, if you're writing .h files and .c files for the functions, you're pretty much writing classes, in concept if not fact. Again, I don't know anything about map.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    10
    I put class as the heading bc i am trying to create the image class,,,,i think i am not explaining myself very well,,,,,here is the deal,,,,,we are given these .h and .c files which are the codes for creating images eg: box,,and line,,and circle etc. All I want to do is to know how to combine these into one class called image,,,is there a way of calling them????
    After creating image then i have to write another function called new which takes the variable "name" and "height" and "width" and creates an image with the identifier name and wait there is more,,,,then another function follows called select which makes the image identified by name the current image,,,,,,therefore the way i am going about it is to create this image class and then have the new object identified by name being put into a map (name,image) ,,,,by the way the images are monochrome (balck and white,,,0 representing white and 1 reperesenting black),,,,so do u guys get what i mean now?????
    sorry for such a long winded post

  7. #7
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You want to create a composite class? If so you want to do something like -


    //image.h

    #include "line.h"
    #include "box.h"
    #include "circle.h"
    //etc

    class image
    {
    line m_line;
    box m_box;
    circle m_circle;
    //other stuff
    };

    Do you mean STL map? Perhaps some code would clarify.
    zen

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    10
    thank you zen so much,,,i think thats exactly what i need,,,and yes i do mean STL map,,,by the way does anyone know where i can find some good exaple coding for maps,,,,i can't find any on the web!!!!

Popular pages Recent additions subscribe to a feed