Results 1 to 3 of 3

Thread: ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    jonyshub's Avatar
    Join Date: Dec:2008
    Location: athens
    Posts: 57

    ++

    :

    - "" , ;
    - - () - (), ;
    - ;
    - Set() ;
    - Print() ;
    - .

    :
    ---------------------------------------------------------------------------
    - name, age, number, : GetName(), GetAge(), GetNumber();
    - / ;
    - , ;

    - : , , , ;
    - : , . , , ;


    , , ? "Set()" , ? , , , , .

    :

    #include<iostream>
    #include
    // - People
    class People
    {public:
    People(char * = , char * = , char * = , );
    void PrintPeople() const;
    ~People();
    private:
    char * name;
    char * egn;
    };
    // People
    People::People(char *str, char *num)
    {name = new char[strlen(str)+1];
    strcpy(name, str);
    egn = new char[11];
    strcpy(egn, num);
    }
    // PrintPeople
    void People::PrintPeople() const
    {cout << Ime: << name << endl;
    cout << EGN: << egn << endl;
    }
    // People
    People::~People()
    {cout << ~People(): << endl;
    delete name;
    delete egn;
    }
    // Student
    class Student : People
    {public:
    Student(char * = , char * = , long = 0, double = 0);
    void PrintStudent() const;
    ~Student()
    {cout << ~Student(): << endl;
    }
    private:
    long facnom;
    double usp;
    };
    // Student
    Student::Student(char *str, char * num, long facn,
    double u) : People(str, num)
    {facnom = facn;
    usp = u;
    }
    // PrintStudent
    void Student::PrintStudent() const
    {PrintPeople();
    cout << Fac. nomer: << facnom << endl;
    cout << Uspeh: << usp << endl;
    }
    // PStudent
    class PStudent : public Student
    {public:
    PStudent(char * = , char * = , long = 0,
    double = 0, double = 0);
    ~PStudent()
    {cout << ~PStudent() \n;
    }
    void PrintPStudent() const;
    protected:
    double tax;
    };
    // PStudent
    PStudent::PStudent(char *str, char *num, long facn,
    double u, double t) : Student(str, num, facn, u)
    {tax = t;
    }
    // PrintPStudent
    void PStudent::PrintPStudent() const
    {PrintStudent();
    cout << Tax: << tax << endl;
    }
    void main()
    {People pe;
    pe.PrintPeople();
    PStudent PStud(Ivan Ivanov, 8206123422″, 42444, 6.0, 4567);
    PStud.PrintPStudent();
    }

  2. #2
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    :

    1. Print(), PrintPStudent()/PrintStudent() .., , . , Print(). , Print()- , ::. , Student::Print() :

    Code:
    //    Print   Student
    void Student::Print() const
    {People::Print();
    ...
    2. copy-constructor operator =" ( , ; - ).

    3. Set(). , , Set - , ( tax") ѝ . , , " (tax PStudent, facnom usp Student ..), - , - Set - . - !
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  3. #3
    jonyshub's Avatar
    Join Date: Dec:2008
    Location: athens
    Posts: 57
    ! !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |