Student - public: Student(int id, string &...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Student.cpp / // Shows how a constructor initializer list is required for // const members, reference members, and members that have // no default constructors. // Updated 11/02/03 / #include <iostream> #include <vector> using namespace std; u class Date { public: Date(int m, int d, int y) { } }; } // Remove mLastName and mBirthDate from the initializer list // and enable the assignment statements in the constructor body: / class Student {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public: Student(int id, string &amp; lname, const Date &amp; bDate) :mID(id), mLastName(lname), mBirthDate(bDate) { //mID = id; // cannot assign a const //mBirthDate = bDate; // no default constructor //mLastName = lname; // cannot assign reference } private: const int mID; string &amp; mLastName; Date mBirthDate; }; } void main() { string lastName = &quot;Baker&quot;; Student s1( 1234, lastName, Date(5,20,1985) ); S }...
View Full Document

This note was uploaded on 10/17/2010 for the course SCIS COP 4338 taught by Professor Kipirvine during the Spring '10 term at FIU.

Ask a homework question - tutors are online