Exforsys
+ Reply to Thread
Results 1 to 3 of 3

calling functions nested in classes using objects from oder classes

This is a discussion on calling functions nested in classes using objects from oder classes within the C and C++ forums, part of the Programming Talk category; Hello, I'm new in c++. In my program I've got 2 classes where I defined some functions. Then I defined ...

  1. #1
    mario-kl is offline Junior Member Array
    Join Date
    Jul 2007
    Answers
    2

    calling functions nested in classes using objects from oder classes

    Hello, I'm new in c++.

    In my program I've got 2 classes where I defined some functions. Then I defined 2 vector-objects of each class and I tried to call one function from the main():

    class class1{
    variables1;
    int t;

    public
    int get_t(){return t;};
    };

    class class2{
    variables2;
    int r;
    class2* c2;

    public:
    int get_r(){return r;};

    void void2(class1* a, class2* b, int m ){
    for(int i=0; i<m; i++){
    if(a->get_r()< b[i]->get_t()){ // whatever, but I don't change anything;}
    }
    };


    main(){

    std::vector<class1*> element1;
    std::vector<class2*> element2;
    int n;
    //I initilize both vectors
    for(int i;i<n; i++){
    element2[i]->void2(element2[i], element1); //How to call the function??
    }
    }


    I tried everything and I red tutorials and nothing wrks. HELP!!

    THX,
    mario-kl.


  2. #2
    norman is offline Member Array
    Join Date
    May 2006
    Answers
    43
    mario-kl,
    Let us know what is the error or output you got. This would help us to solve your problem quicker. Also let me know in what environment that is operating system you are running this program.


  3. #3
    mario-kl is offline Junior Member Array
    Join Date
    Jul 2007
    Answers
    2

    Thank you Norman

    Hey Norman, it was a long time ago. I didn't even remember that I posted that problem, that finally I solved.
    Thanks anyway, because I had the feeling of being invisible

    Have fun!


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...