lundi 27 avril 2015

Inserting values of class to ordered Linked list - C++

I have class Info, and in main.cpp I would like to create object implemented with Ordered Linked List of type Info like orderedLinkedList<Info> object1;

Can some explain how to insert values (first name, last name and birth year).

#ifndef _INFO_H
#define _INFO_H

#include <iostream>
#include <string>

class Info{

        private:
        std::string _first_name;
        std::strign _last_name; 
        int _birth_year;
    
    public:
        Info()=default;
        ~Info()=default;
        Info(string first_name, string last_name, int birth_year):_first_name(first_name), _last_name(last_name), _birth_year(birth_year) {}

        string fName() {return _first_name;}
        string lName() {return _last_name;}
        int bYear() {return _birth_year;}
        
        void setInfo(string first_name, string last_name, int birth_year);          
    

};

void Info::setInfo(string first_name, string last_name, int birth_year)
{
        _first_name = first_name;
        _last_name = last_name;
        _birth_year = birth_year;
}

#endif

Aucun commentaire:

Enregistrer un commentaire