Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- class Student {
- public:
- char * name;
- int id;
- char * gender;
- int level;
- void studentSet(char * n, int i, char *gen, int lvl) {
- name = new char[strlen(n) + 1];
- strcpy(name, n);
- id = i;
- gender = new char[strlen(gen) + 1];
- strcpy(gender, gen);
- level = lvl;
- }
- void studentShow() {
- cout << "Name -> " << name << '\n';
- cout << "Id -> " << id << '\n';
- cout << "Gender -> " << gender << '\n';
- cout << "Level -> " << level << '\n';
- }
- };
- class Exam : public Student {
- public:
- char * examName;
- int totalCourses;
- int *marks;
- void examSet(char *s, int i, int m[]) {
- examName = new char[strlen(s) + 1];
- strcpy(examName, s);
- totalCourses = i;
- marks = new int[totalCourses + 1];
- for(int i = 0; i < totalCourses; i++) {
- marks[i] = m[i];
- }
- }
- void examShow() {
- studentShow();
- cout << "Exam Name -> " << examName << '\n';
- cout << "Total courses -> " << totalCourses << '\n';
- for(int i = 0; i < totalCourses; i++)
- cout << "Marks -> " << marks[i] << '\n';
- }
- };
- class Result : public Exam {
- public:
- int totalMarks() {
- int res = 0;
- for(int i = 0; i < totalCourses; i++)
- res += marks[i];
- return res;
- }
- bool ok = false;
- void result() {
- int cnt = 0;
- for(int i = 0; i < totalCourses; i++) {
- if(marks[i] >= 40)
- ok = true;
- else {
- ok = false;
- cnt++;
- }
- }
- if(ok) cout << "Passed in all subjects\n";
- else cout << "Failed in " << cnt << " subjects\n";
- }
- };
- class Movie{
- public:
- char * movieName;
- char * genre;
- int releaseYear;
- int duration;
- void movieSet(char * name, int year, int times, char * gen) {
- movieName = new char[strlen(name) + 1];
- strcpy(movieName, name);
- genre = new char[strlen(gen) + 1];
- strcpy(genre, gen);
- releaseYear = year;
- duration = times;
- }
- void movieShow() {
- cout << "Movie Name -> " << movieName << '\n';
- cout << "Release Year -> " << releaseYear << '\n';
- cout << "Duration -> " << duration << '\n';
- cout << "Genre -> " << genre << '\n';
- }
- };
- class Animation : public Movie {
- public:
- char * graphicsCreator;
- char * leadVocal;
- void set(char *gchar, char *vchar) {
- graphicsCreator = new char[strlen(gchar) + 1];
- leadVocal = new char[strlen(vchar) + 1];
- strcpy(graphicsCreator, gchar);
- strcpy(leadVocal, vchar);
- }
- void show() {
- movieShow();
- cout << "Graphics Creator -> " << graphicsCreator << '\n';
- cout << "Lead Vocal -> " << leadVocal << '\n';
- }
- };
- int main() {
- Exam E;
- Result R;
- R.studentSet("Fuad", 42, "Male", 2);
- int k[] = {10, 20, 30, 40, 50};
- R.examSet("First", 5, k);
- R.examShow();
- R.result();
- }
- ///
- #include <stdio.h>
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- class Person{
- public:
- char * name;
- int age;
- char * gender;
- void personSet(char * s, int a, char *gen) {
- name = new char[strlen(s) + 1];
- strcpy(name, s);
- age = a;
- gender = new char[strlen(gen) + 1];
- strcpy(gender, gen);
- }
- void personShow() {
- cout << "Name -> " << name << '\n';
- cout << "Age -> " << age << '\n';
- cout << "Gender -> " << gender << '\n';
- }
- };
- class Employee : public Person {
- public:
- char * designation;
- char * department;
- int salary;
- void employeeSet(char *occ, char * d, int t) {
- designation = new char[strlen(occ) + 1];
- strcpy(designation, occ);
- department = new char[strlen(d) + 1];
- strcpy(department, d);
- salary = t;
- }
- void employeeShow() {
- personShow();
- cout << "Designation -> " << designation << '\n';
- cout << "Department -> " << department << '\n';
- cout << "Salary -> " << salary << '\n';
- }
- };
- class Customer : public Person {
- public:
- char * accountType;
- char * accountNo;
- int balance;
- void customerSet(char *s, char *a, int b) {
- accountType = new char[strlen(s) + 1];
- strcpy(accountType, s);
- accountNo = new char[strlen(a) + 1];
- strcpy(accountNo, a);
- balance = b;
- }
- void showAll() {
- personShow();
- //employeeShow();
- cout << "Account type -> " << accountType << '\n';
- cout << "Account no -> " << accountNo << '\n';
- cout << "Balance -> " << balance << '\n';
- }
- };
- int main() {
- Customer C;
- C.personSet("Fuad", 22, "Male");
- //C.employeeSet("Teacher", "CSE", 30000);
- C.customerSet("Normal", "101010", 45000);
- C.showAll();
- }
- ////
- #include <stdio.h>
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- class Department {
- private:
- char * name;
- protected:
- int id;
- public:
- void set(char *c, int i) {
- name = new char[strlen(c) + 1];
- strcpy(name, c);
- id = i;
- }
- void show() {
- cout << name << ' ' << id << '\n';
- }
- };
- class Institute : public Department {
- private:
- char *name;
- protected:
- int id;
- public:
- void set(char *c, int i, char *s, int j) {
- Department :: set(s, j);
- name = new char[strlen(c) + 1];
- strcpy(name, c);
- id = i;
- }
- void show() {
- cout << Institute :: name << ' ' << Institute :: id << ' ' <<'\n';
- Department ::show();
- }
- };
- int main(){
- Institute I;
- I.set("MIST", 10, "CSE", 20);
- I.show();
- }
- ///
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement