0% found this document useful (0 votes)
6 views4 pages

C++ Class Implementation Example

The document contains C++ code defining three classes: Instructor, TextBook, and Course. Each class includes constructors, copy constructors, and methods for setting and printing attributes. The main function creates instances of these classes and prints the details of a course along with its instructor and textbook.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

C++ Class Implementation Example

The document contains C++ code defining three classes: Instructor, TextBook, and Course. Each class includes constructors, copy constructors, and methods for setting and printing attributes. The main function creates instances of these classes and prints the details of a course along with its instructor and textbook.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ASSIGNMENT # 03;

#include <iostream>

#include<iostream>

using namespace std;

class Instructor

string lastname,firstname,officename;

public:

Instructor()

Instructor(string lname,string fname,string office)

lname=lastname;

fname=firstname;

office=officename;

Instructor(Instructor &ins)

lastname=[Link];

firstname=[Link];

officename=[Link];

void setname(string lname,string fname,string office)


{

lastname=lname;

firstname=fname;

officename=office;

void print()

cout<<"Last name="<<lastname<<endl;

cout<<"First name="<<firstname<<endl;

cout<<"Office name="<<officename<<endl;

};

class TextBook

string title,author,publisher;

public:

TextBook()

TextBook(string t,string auth,string pub)

t=title;

auth=author;

pub=publisher;

TextBook(TextBook &ins)

{
title=[Link];

author=[Link];

publisher=[Link];

void settext(string t,string auth,string pub)

title=t;

author=auth;

publisher=pub;

void print1()

cout<<"Title="<<title<<endl;

cout<<"Author="<<author<<endl;

cout<<"Publisher="<<publisher<<endl;

};

class Course

string coursename;

Instructor instructor;

TextBook textBook;

public:

Course(string name,Instructor &inst,TextBook &text)

name=coursename;

void print()
{

cout<<"Course name="<<coursename<<endl;

[Link]();

[Link]();

};

int main()

Instructor i1("Kramer","Shaw","RH3010");

TextBook t1("Starting with c++","Gradius","Addision");

Course c1("oop",i1,t1);

[Link]();

return 0;

You might also like